Ch 3 · Stacks — Last In, First Out · Data Structures & Algorithms
Topic 3 of 10 in Data Structures & Algorithms — Foundations — 2 lessons.
What Is a Stack?
A stack only lets you touch the top. You push an item on top, and you pop the top item off. The last thing in is the first thing out — LIFO. Think of a pile of plates: you take the one you just put down.
Stacks in Action: Balanced Brackets
Editors check that your (, [, { all close in the right order. That is a stack: push every opener, and when you meet a closer, the top of the stack must be its match.
All topics in Data Structures & Algorithms Beginner
- Thinking Like a Computer Scientist
- Arrays & Lists — The Workhorse
- Stacks — Last In, First Out
- Queues — First In, First Out
- Linked Lists — Nodes on a Chain
- Searching — Finding the Needle
- Sorting — Putting Things in Order
- Recursion — Functions That Call Themselves
- Hash Tables — Instant Lookups
- Mini-Projects & Practice