A stack is a Last-In-First-Out (LIFO) data structure. Think of a stack of plates: you add plates to the top and remove plates from the top.
Three operations:
- Push: add an element to the top
- Pop: remove and return the top element
- Peek (or top): view the top element without removing it
All three operations are . You never access elements in the middle directly.