TOPIC

Queues

FIFO and its variants: linear, circular, deque and priority.

WHY DID WE NEED QUEUES?

THE WALLStacks serve the NEWEST first — unfair and wrong for scheduling: the first print job, the first network packet, the first customer should go first.

THE IDEARestrict the other way: enqueue at the back, dequeue from the front — FIFO. Arrival order is preserved, both ends O(1).

Any queue at a counter: first come, first served. Printer spoolers, task schedulers and BFS all run on this.

Choose a category