Level 2 · Core Data StructuresBUILD YOUR INTUITION
Queue
Process items in the order they were discovered. The oldest unfinished item leaves first.
THE MENTAL MODELWhen should this come to mind?
Process items in the order they were discovered. The oldest unfinished item leaves first.
Breadth-first explorationTasks ready to processArrival order What makes it work
An array with a head index avoids repeatedly shifting all remaining elements. Mark discoveries when enqueuing.
When to choose something else
Nested or most-recent unfinished work belongs on a stack; weighted priorities call for a heap.
See the pattern in action
Change the input. Follow the state. Make it yours.