not able to understand the logic of inserting at bottom,i mean i know why it is required but how its recursive cases is working ?
Reverse stack using recursion
there are two recursive function first to empty the stack then to fill it
when u empty all the element of the stack then u call another function which insert in the stack whenever it is empty
therefore when the first element come the stack is already empty therefore u push the element
but second time when this function is called then u have to first empty this stack and when the stack is empty u insert the element and return from there while returning the second function insert the element which is present in it . so we get a recursive stack Also pass by reference is imp.
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.