we are performing stack reverse with 1 extra stack
so if the input is 1>2>3>4 the output should be 4>3>2>1
but why sir got 1>2>3>4
Stack reverse with 1 extra stack
@abhinavakhil55 Stack follows Last In First Out Property.
If the initial stack was 1>2>3>4
The reversed stack will be 4>3>2>1
But when you print the reverse stack, you will have to print from top to bottom that is in order 1>2>3>4
In a stack, only after accessing the top element, you can access the element below it.
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.