Assuming that the circular queue is stored in QU with size N.
Check if Queue already filled or not
Step 1.if (FRONT = 1 and REAR = N) or (FRONT = REAR + 1) then
{
write "Overflow !!"
}
else
{
Step 2.if FRONT = NULL then
{
set FRONT = 1
REAR = 1
}
Step 3.else if REAR = N then
set REAR = 1
else
Step 4.set REAR = REAR + 1
}
// end of if
Step 5.set QU[REAR] = I_ITEM // (to insert the new item I_ITEM)
Step 6.return.
Read also:- Algorithm to delete an element in a circular queue
This is the algorithm to insert an element in a circular queue. If you have any query then tell me by commenting below.