Question: 5.3 Write an algorithm that displays all the characters in a stack in the order in which they were pushed onto the stack. After all
5.3 Write an algorithm that displays all the characters in a stack in the order in which they were pushed onto the stack. After all the characters are displayed, the stack should have the same contents as when you started. In your method, you can only use the stacks operation, and NO explicit index can be declared to locate the items in the stack. Also, write the main() function to test your algorithm.
For example: After you push a, b, c in an empty stack, you methond should display a, b, c.
Please note, if you refer to the stack class the instructors example code, dont forget to change the data type from long to char. Also, there are many ways to implement this algorithm, open your mind~
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
