Stacks Exercises
- List the basic operations of a stack (and explain each one to the members at your table)
- Identify the Big-O for each of the basic operations
- Identify multiple examples of stacks in everyday life
- Compare and contrast lists and stacks (for example, which methods need to be changed?)
- Write the contents of an array stack after each of the following operations (be sure to clearly indicate the top element in the stack):
- push( A )
- push( B )
- pop( )
- push( C )
- pop( )
- pop( )
Repeat with a linked stack.
- Write the contents of an array stack after each of the following operations (be sure to clearly indicate the top element in the stack):
- push( 's' )
- push( 't' )
- push( 'r' )
- push( 'e' )
- push( 's' )
- push( 's' )
- push( 'e' )
- push( 'd' )
- pop( )
- pop( )
- pop( )
- pop( )
- pop( )
- pop( )
- pop( )
- pop( )
Repeat with a linked stack.
What word is formed from the collective calls to pop?
-
Linked stack demo: Pushes p, o, o, and l onto a stack and then pops each one of them off (with adapted code from the textbook).
Last Modified: