AlgoScope

Dequeue

Remove the item at the front, which has waited longest.

Stack and queue algorithms, algorithm, beginner
Dequeue removes 5 from the front. 2 items remain.39frontrearfrontrear

Queue: Enqueue, dequeue, peek

Decision, step 5 of 10

dequeue returns 5: the item that waited longest leaves first.

Cost

Best
O(1)
Average
O(1)
Worst
O(1)
Space
O(1)

Before this

Taught by the same lesson

Queue covers these too, in the same run.