Problem

(Stringpermutations) Write a recursive function to print all permutations of a string. For...

(Stringpermutations) Write a recursive function to print all permutations of a string. For example, for a string abc , the permutation is

abc

acb

bac

bca

cab

cba

(Hint:Define the following two functions. The second is a helper function.)void displayPermuation(const string& s)

void displayPermuation(const string& s1, const string& s2)

The first function simply invokes displayPermuation("", s). The second function uses a loop to move a character from s2 to s1 and recursively invoke it with a new s1 and s2. The base case is that s2 is empty and prints s1 to the console.

Write a test program that prompts the user to enter a string and displays all its permutations.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT