Stack¶
Definition¶
A Stack is a data structure where elements are inserted into and removed from the head of the container.
Motivation¶
Sequential
Limited access
Last-In First-Out (LIFO) access
Linear
- When might I actually use this?
- Towers of Hanoi puzzle
- Rearranging railroad cars
- Sorting...anything
Attributes¶
- top
- is_empty
- size
Operations¶
- push(item)
- pop()