AlgoScope

Enqueue

Add an item at the rear. It waits behind everything already there.

Stack and queue algorithms, algorithm, beginner
Enqueue 5 at the rear. The queue has 1 item. The front is 5.5frontrearfrontrear

Queue: Enqueue, dequeue, peek

Step, step 2 of 10

enqueue 5 and it joins at the rear. Size 1.

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.