Sir what if our ques ask for the output in sorted order

abc
acb
bac
bca
cba
cab
this is the output we get from the algo that we were taught in this video
how we will able to make our output in ascending order without using sorting function
directly by making change in algo

@pankajsingh you can store all the strings in a set, they’ll automatically be stored in sorted manner and only unique strings will be stored.

can we do this without using any extra space by recursion

hi @pankajsingh you can refer to this

the page u are asking me to refer is doing exactly same as we did in the video this is not the ans of my question. mam please go through my question again

hi @pankajsingh sorry my bad, the above program is for repeated elements in the string, not for sorted output. All the algorithms for sorted output of permutations are using some variations of maps or sets. https://www.geeksforgeeks.org/print-distinct-sorted-permutations-with-duplicates-allowed/?ref=rp this program has smaller space complexity as it is not storing all the permutations in a set, but it may need more stack memory