Write a recursive method to print all the permutations of


Write a recursive method to print all the permutations of a string. For instance, for a string abc, the printout is: abc acb bac bca cab cba. Use the following two methods, the second one being a helper method:

public static void displayPermutations(String string)

private static void displayPermutations(String prefix, String string)

The first method simply invokes displayPermutations("", string). The second method uses a loop to move a character from string to prefix and recursively invoke it with the new prefix and string. The base case is when string is empty, and prints prefix to the console.

Your program should compile and run without errors.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Write a recursive method to print all the permutations of
Reference No:- TGS01675804

Now Priced at $35 (50% Discount)

Recommended (92%)

Rated (4.4/5)