AlgoScope

Circular Queue

A fixed array where front and rear indices wrap around, so no space is wasted.

Data structures, data structure, beginnerAlso called ring buffer
Enqueue 3 into slot 1. Size 2.503123frontrear
Enqueue 3 into slot 1. Size 2.503123frontrear

Circular Queue: Rear wraps around

Decision, step 3 of 10

enqueue 3 into slot 1, one past the old rear. Size 2.

Cost

Enqueue
O(1)
Dequeue
O(1)
Space
O(capacity)