Dequeue
Remove the item at the front, which has waited longest.
Decision · step 5 of 10Queue: Enqueue, dequeue, peek
dequeue returns 5: the item that waited longest leaves first.
What you will see
The FRONT item leaves; everyone behind keeps their order.
Cost
| Best | O(1) |
|---|---|
| Average | O(1) |
| Worst | O(1) |
| Space | O(1) |
How you work with it here
play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next, try operations in any order.
Screen readers: Items announce position from the top or front and value; each step announces the operation and the new top or front.
Reduced motion: Items appear or disappear in place with a crossfade instead of sliding in or out.