Circular Queue (Ring Buffer)

Efficiently utilizes space by connecting the end back to the start.

0
1
2
3
4
Indices wrap around: 4 ➔ 0
Size: 0 / 5Status: Queue is empty.
Speed

Algorithm Logic

1function enqueue(val):
2 if isFull():
3 return Overflow
4 rear = (rear + 1) % capacity
5 queue[rear] = val
6 if front == -1: front = 0
7 size++
Capacity: 5