Stacks, Queues & Deques
Choose and implement LIFO and FIFO structures and apply them to parsing, undo and level-by-level processing.
3 objectives 5 steps about 100 min
Check what you know
The lessons are coming later. The knowledge check is ready now.
This skill page is a public outline. Its lessons and knowledge check appear here as subject-matter experts approve them.
Learning objectives
- Implement a stack and a FIFO queue (list, collections.deque, ring buffer) with O(1) core operations, and explain why list.pop(0) is a performance trap.
- Solve matching and evaluation problems with a stack, such as balanced brackets and arithmetic expression evaluation.
- Build a queue from two stacks and a stack that reports its minimum, and justify their amortized or worst-case costs.
Lesson plan
5 steps, about 100 min · 0 of 4 lessons available so far
- LIFO and FIFO as Contracts Concept · 15 min · coming later
- Lab: A Fixed-Capacity Ring Buffer Lab · 25 min · coming later
- Stacks for Parsing and Matching Worked example · 25 min · coming later
- Composite Designs: Two-Stack Queue and Min-Stack Worked example · 20 min · coming later
- Check: Stack and Queue Scenarios Knowledge check · 6 questions
Practise it
Write an evaluator for arithmetic expressions with + - * / and parentheses using two stacks, plus a fixed-capacity ring-buffer queue; both must pass the provided tests, including malformed expressions and full or empty buffers.
Build it from scratch
Practice builds that exercise this skill by re-creating a real technology.
- Build your own JSON ParserIntro · 3–6 h
- Build your own Programming LanguageIntermediate · 20–40 h
References
Hard prerequisites
Unlocks
On these roadmaps
Progress and evidence for this skill are shared across all of them.