-
recursion problem
I am working on a project and I need some help on one part.
How do you write a recursive function to rearrange strings (permutations) in all possible combinations.
Like if the input was ABC:
ABC
ACB
BAC
BCA
CAB
CBA
would you switch letters or is there an easier way...
Thanks,
Dustin
-
Something based on this perhaps
"A" + permute("BC")
"B" + permute("AC")
"C" + permute("AB")
Basically, put each char in the left position in turn, and permute the rest.
permute stops being recursive when you do permute("")