hints to solve this recursive programming problem???

laFiera

Senior member
May 12, 2001
862
0
0
I must not have a recursive brain. That's the part of discrete math that i struggled with, and now this programming problem... i've been trying to come up with an algorithm for this problem for the last two days to no avail.......if you guys have any hints how to confront it, let me know...
help is greatly appreciated... :)



The function arrange is a recursive function which has two inputs, first and second which are both strings (from our string ADT of Chapter 4). The function prints all rearrangements of the letters in first, followed by second. For example, if first is the string "CAT" and second is the string "MAN", then the function would print the strings CATMAN, CTAMAN,ACTMAN, ATCMAN, TACMAN, and TCAMAN. The stopping case of the function occurs when the length of first has zero characters.

Implement the function arrange with the specification below.

void arrange(String first, String second);
// Postcondition: All rearrangements of the letters in first, followed by
second are printed to cout.

It will be easier to implement this function if the string class has the
additional methods:

void insert(size_t position, char c);
Postcondition: A copy of character c has been inserted into the string
at the indicated position. Existing characters that used to be at or
after the given position have been shifted right one spot.

void remove(size_t position, size_t n);
Precondition: position + n <= length( ).
Postcondition: n characters have been removed from the string, beginning at
the specified position.