I'm given a string that I need to find all permutations of, the thing is I'm restricted to calling it recursively and it returning void, taking only one string parameter:

Code:

void permute(string& word);

The thing Is I just can't work out why it can be recursive. I would understand if it took another parameter, possibly int fact, which would be the n! which is how many times it would need to call itself, reaching a base case that:

I've figured out a routine to do the permutation, which is just moving around a substring of the words exluding the first, then just going down the word, but I'm restricted to using one parameter. Maybe I'm just not good at the recursion.

10-10-2006

SKeane

What about taking each character in the string and recursively calling the function on the remaining characters, until you call the function with only one character (this ends the recursion).

10-10-2006

indigo0086

I was able to get the first line of permutations, but If i recursively "shrink" the string, I will not be able to display the letter of the previous string that would make the permutation for each letter being the first of the string