Recusrion dictionaery -

all testcase not passing here id the link-

Please share the question

@pratyush63 here is the question ----- Take as input str, a string. Write a recursive function which prints all the words possible by rearranging the characters of this string which are in dictionary order larger than the given string

Your code is generating the correct permutations but not printing in correct order.
Consider a case: ABC
Your Code output:
ACB
BAC
BCA
CBA
CAB
Expected Output:
ACB
BAC
BCA
CAB
CBA

@pratyush63 sir how can i do this can u give some hint


Refer this solution

@pratyush63 sir why we are not backtracking here

also can u suggest me how can i use an another array to save the current outputs by an example

Actually the correct ordering is achieved without backtracking in this case.
Both with backtracking and without backtracking will give the correct permutations but arranged in different order.
Here in this problem you need the order formed just by the recursive way. But note that the parameters passed to recursive function are passed by value (as in string ) and not by reference. If it is passed by reference, you will notice that it will give the wrong permutations. In that case backtracking would be necessary.

1 Like

okay sir got it thanks

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.