AlgoScope

Queue

You join at the back and leave from the front, like a queue at a counter.

Data structures, data structure, beginnerAlso called FIFO
Empty queue with capacity 6. Running 8 operations: enqueue 5, enqueue 3, enqueue 9, dequeue, peek, enqueue 7, dequeue, dequeue.
Empty queue with capacity 6. Running 8 operations: enqueue 5, enqueue 3, enqueue 9, dequeue, peek, enqueue 7, dequeue, dequeue.

Queue: Enqueue, dequeue, peek

Start, step 1 of 10

An empty queue. Things join at the REAR and leave from the FRONT.

Cost

Enqueue
O(1)
Dequeue
O(1)
Peek
O(1)
Search
O(n)
Space
O(n)

Before this

Leads to

Topics that need this one first.

Taught by the same lesson

Queue covers these too, in the same run.