Write code in Java: -Must be recursive import java.util.*; import java.lang.*; import java.io.*; //*Analysis goes here* //*Design goes here* class AllPermutation { public static void...



Write code in Java:



-Must be recursive


import java.util.*;


import java.lang.*;


import java.io.*;


//*Analysis goes here*



//*Design goes here*


class AllPermutation {


public static void displayPermutation(String s) {


//*Code goes here*


}


public static void displayPermutation(String s1, String s2) {


//*Code goes here*


}


}


//*Driver class shouldnot be changed*


class DriverMain {


public static void main(String args[]) {


Scanner input = new Scanner(System.in);


AllPermutation.displayPermutation(input.nextLine());


}


}


Write a recursive method to print all the permutations of any string. For example, for the string abc:<br>abc<br>acb<br>bac<br>bca<br>cab<br>cba<br>using two given methods:<br>void displayPermutations(str)<br>void displayPermutations (str1, str2) //helper<br>Note: Helper method, uses a loop to move a character from str2 to stri and recursively invokes it with a new stri and str2. The base case is that str2 is empty and<br>print stri to the console.<br>//Assume no duplicate characters or space in the input string<br>

Extracted text: Write a recursive method to print all the permutations of any string. For example, for the string abc: abc acb bac bca cab cba using two given methods: void displayPermutations(str) void displayPermutations (str1, str2) //helper Note: Helper method, uses a loop to move a character from str2 to stri and recursively invokes it with a new stri and str2. The base case is that str2 is empty and print stri to the console. //Assume no duplicate characters or space in the input string

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here