Stacks
The notes
Core concept
- LIFO principle (last-in, first-out)
- Elements are accessed only from one end (the top)
- The last thing I put here is the first thing I get
- Pictured as a stack of plates with a top and a bottom
Key operations
- push(item): add an element to the top
- pop(): remove the top element
- peek(): view the top element without removing it
Real-world examples
- Undo / redo: actions and undo history
- Function calls (call stack): managing function execution and recursion (main(), func1(), func2(), func3() pushed and popped)
- Browser history: back and forward through pages
- Expression parsing: converting (A+B)*C to postfix notation
Data structures deck
Make them stick
Sign in to see every card full size, tick the ones you've got, come back to the rest later, and keep your own notes on each card.
Watch the lesson
Data structures, Lesson 3, from 1:20: How does a stack look and behave?








