In this problem, We have to write a code to sort a stack using recursion. We have to sort in a descending order (Top of the stack has the greatest element).
We don’t have to use any loop constructs ( for, while etc) or additional data structure.
For Example –
In this example, You can see after sorting the stack, the element which has greater value is at the top of the stack.