Recursion tree backward swapping

When sir drew recursion tree and when he went backward in the recursion tree sir said that swapping will still be done but i am not able to understand that how he knows which index would be swapped by which ?

hi @pranjuldwivedi120568 we also pass an index i to keep track of which character to swap.

can u show me that with a diagram how i and j values vary

@pranjuldwivedi120568 in this the indices aren’t mentioned but you can clearly see which element is being swapped, I hope it helps

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.