+ 2
How to create a recursive method that could find permutations of a string?
For example: String str = “ABC”; After execute the recursive method in main(), the output will be something like this: Public static void main(String a[]) { System.out.println(permutations(“ABC”); } => output: ABC ACB BCA BAC CAB CBA Thanks for reading!! ❤️
5 ответов
+ 4
Recursion is calling the same function after with itself. A visual example is two mirrors facing each other. The key is when to break...
+ 3
Recursion is very trick, one has to be fairly skilled in working with loops before leaping into it. I advise that you start with very simple loops and try to implement the same function using recursion...
+ 1
Is the above permutation restricted to three characters?
Or from 1 to 3 characters
+ 1
Da2 I’m pretty comfortable with loop. I just can’t figure out the algorithm to produce the required output (yet)
0
Ani Daniel No, it suppose to work with any string input (but let say the input only have 3-5 characters)