A Circular Queue uses a fixed-size array where the end wraps around to the beginning. When the queue is full, you can't add more — but when an element is removed from the front, that space becomes available at the end.
Key idea: Use two pointers — head and tail — with modular arithmetic:
head: Index of front elementtail: Index where next enqueue goes(index + 1) % capacitycount to distinguish full vs emptycq.enQueue(1)
True
cq.enQueue(2)
True
cq.enQueue(3)
True
cq.enQueue(4)
False
cq.Rear()
3
cq.isFull()
True