Sort a stack using recursion - GeeksforGeeks
Sort a stack using recursion
Given a stack, sort it using recursion. Use of any loop constructs like while, for..etc is not allowed. We can only use the following ADT functions on Stack S:
is_empty(S) : Tests whether stack is empty or not. push(S) : Adds new element to the stack. pop(S) : Removes top element from the stack. top(S) : Returns value of the top element. Note that this function does not remove element from the stack.
Read full article from Sort a stack using recursion - GeeksforGeeks
No comments:
Post a Comment