2023-08-01 18:20:59 -07:00
..
2023-07-30 21:47:10 -07:00
2023-08-01 18:20:59 -07:00
2023-07-31 10:11:16 -07:00

stacks


  • last in, first out structures (LIFO)
  • useful in certain recursive algorithms, where you can push temp data as you recurse, and remove them from the (memory or data structure) stack as you backtrace.


examples


stack.py


python3 stack.py

Testing Stack...

Stack: [12, 13, 14, 15, 16, 17, 18, 19, 20]
Stack size: 9
Stack peek: 20
Stack is empty: False
Stack min: 12

Popping...
20
19
18
17
16
Stack: [12, 13, 14, 15]