Learn › Stacks & queues

Where they shine

Bracket matching, undo histories, and the searches you've already met. · 6 min read

Stacks power anything with nesting or reversal: matching brackets, the undo/redo history in your editor, evaluating arithmetic expressions, and the function call stack itself.

Interactive visualization: Matching brackets: push opens, pop on closes — step through it frame by frame on this page.

Queues power anything processed in arrival order: print spoolers, task schedulers, and breadth-first search. Remember pathfinding — BFS used a queue to explore in rings, DFS used a stack to plunge deep. The container is the algorithm.

Interactive visualization: FIFO: processed in arrival order — step through it frame by frame on this page.

Previous: Queues (FIFO) · Next: Hash tables

More in Stacks & queues