Stack reverse using recursion


using stack reverse getting 1 1 1 1 1 as output not able to figure what’s wrong in code

Hi @hrishikeshjanjal
You are getting 1 1 1 1 1 as output because in the insertatbottom function in line number 34 you are passing y as argument ans after that again pushing y back into stack. So just replace y by x then you will get your desired output.

Here is your corrected code :

Hi @hrishikeshjanjal
Mark your doubt as resolved if you get what was wrong with you code.

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.