Let 'Perms' be the set of permutations found, and 'Used' the list of selected characters.
Find permutations of n characters from the set S:
- If n = 0, then Used is a permutation. Add it to Perm and return.
- For every char C in S:
- Remove C from S and add (or press) it to U.
- Find permutations of n-1 characters from S.
- ( ) U C S.
n , Perms .
, . , , .