queue

A collection where items leave in the order they arrived: first in, first out, like a line at a shop counter.

In more detail

Items are enqueued at the back and dequeued from the front. In Python, use collections.deque with append and popleft, both O(1); a list with pop(0) is O(n) per removal. Queues drive breadth-first search, job scheduling and producer-consumer pipelines.

Related terms

Taught in

References