Question: How to reverse the elements of stack only using stack operations pop() and push() for example 2345 would read 5432. Ive provided some code along
2) For our MyStack class we created methods emptyCheck() which returns True if the stack becomes empty; top), that returns the value of the top element in the stack; push(a1) that places the value of al onto the top of the stack; and popi) that removes the top element of the stack, if any. To process any stack, you may only use those routines and some primitive data variables to temporarily store a value or two. If necessary, you can temporarily create a second stack to store values. a) Design a method in MyStack called getBottomValue() that returns the values at the bottom of the stack. Design a method in MyStack called stackStack(MyStack that pushes the values from stack T, in the correct order. When the routine is done, the top element in the ("this") stack should be the top element from T. T should also be restored to its original condition. b) Illustration Stack T 6 The ('this") Stack Resulting "this" Stack
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
