Circular Queue
A fixed array where front and rear indices wrap around, so no space is wasted.
Circular Queue: Rear wraps around
enqueue 3 into slot 1, one past the old rear. Size 2.
Cost
- Enqueue
- O(1)
- Dequeue
- O(1)
- Space
- O(capacity)
A fixed array where front and rear indices wrap around, so no space is wasted.
enqueue 3 into slot 1, one past the old rear. Size 2.