## What is Circular Queue?

Circular Queue is a linier Data Structure in which elements are arranged such that first element in the queue follows the last element. The limitation of simple queue is that even if there is a free memory space available in the simple queue we can not use that free memory space to insert element. Circular Queue is designed to overcome the limitation of Simple Queue.

## Operations Performed on Circular Queue Download Algorithm & Program

There are two main operations that can be performed on Circular Queue.

## Insert Operation

Insert operation is used to insert an element into Circular Queue.
In order to insert an element into Circular Queue first we have to check weather space is available in the Circular Queue or not. If Circular Queue is full then we can not insert an element into Circular Queue. If value of REAR variable is greater then or equal to SIZE – 1 and value of FRONT variable is equal to 0 then we can not insert an element into Circular Queue. This condition is known as “Overflow”.
If Queue is not overflow then we have to set the value of REAR variable and then we can insert an element into Circular Queue.

Step 1: If REAR = SIZE-1 then
REAR = 0
Else
REAR=REAR + 1
Step 2: If FRONT = REAR then
Write ("Circular Queue Overflow")
Step 3: CQ[REAR]=X
Step 4: If FRONT = -1 then
FRONT=0

## Delete Operation

Delete operation is used to delete an element from Circular Queue.
In order to delete an element from Circular Queue first we have to check weather Circular Queue is empty or not. If Circular Queue is empty then we can not delete an element from Circular Queue. This condition is known as “Underflow”.
If Circular Queue is not underflow then we can delete an element from Circular Queue.
After deleting an element from Circular Queue we have to set the value of FRONT and REAR variables according to the elements in the Circular Queue.

Step 1: If FRONT = -1 then
Write ("Circular Queue Underflow")
Step 2: Return (CQ [FRONT])
Step 3: If FRONT = REAR then
FRONT=REAR=-1
Step 4: If FRONT = SIZE-1 then
FRONT=0
Else
FRONT=FRONT+1