sir in this questions test case i’m not able to understand the order in which output is being printed if acc. to question they are asking to print all words smaller then the given word then output should be like
abc
acb
bac
bca
but in the given test case in the output 1,2 and 3,4 are swapped why?
Recursion question dictionary smaller
Hey Rahul, if input : cab
output:
abc
acb
bac
bca
it is the sorted output i.e if you store all the strings of smaller lexicographical order and sort them you will get this output but
output:
acb
abc
bca
bac
this is the you will get during the recursion if you put a print statement in base case(i.e when we have a smaller lexicographical permutation of the string).
Hope it helps you