Question: ( a ) Write a function: reverseStack ( Stack st ) , which prints the contents of the stack st in reverse ( i .

(a) Write a function: reverseStack(Stack st), which prints the contents of the stack st in reverse (i.e., the top of the stack is printed last).
You are allowed only to use another stack, Stack st2. That is, you cannot use any arrays etc. The only functions you can use on stacks are pop(), push() and empty().(Hint: You put the contents of one stack into another by popping and pushing. Is the order the same?)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!