Circular queue
Circular queue is based on the principle of FIFO or First-In-First-Out, only exception being the last element is connected to the first one. This is also known as ring buffer.
Operations of circular queue
Various operations performed by the circular queue are as follows:
- Front(): It gets the front element from the queue.
- End(): It gets the rear element from the queue.
- enQueue(): It inserts new value in the queue.
- deQueue(): It deletes new value in the queue.
Applications of circular queue
Applications of circular queue are as follows:
- It provides memory management.
- The operating system uses it to insert and execute processes.
- Traffic control is one of the best examples of circular queue.
Enqueue operation
Queues can be inserted when they are not full, and there are two such scenarios:
- When rear!=max-1, then the rear value is incremented to mod, and the new value obtained is inserted at the rear end.
- When front!=0 and rear=max-1, then the value for rear is set to 0, and a new element is inserted.
The two situations in which the element cannot be inserted are as follows:
- When the front==0 and rear=max-1.
- When front==rear-1.
Dequeue operations

Reference