โ Back to the queues page
Simple FIFO Queue
First in, first out. The fairness structure: whoever waited longest is served next. BFS is "a queue applied to a graph".
What to know
- BFS explores in rings of increasing distance โ the queue is what enforces that order.
- Implemented over a circular buffer or linked list for O(1) at both ends.
- Level-order tree traversal = BFS with a size snapshot per level.
In the wild: Print queues, message brokers (Kafka partitions, SQS), request queues, ticket lines.
Algorithms to reach for
BFS traversal
O(V + E)Shortest unweighted paths, level-order walks
Multi-source BFS
O(V + E)Spread from many starts at once (rotting oranges)
Recent counter / moving window
O(1) amortizedCount events inside a time window
Practice problems โ with full guides
Each problem has its own page: progressive hints, how to approach it, and the full solution.