Write An algorithm of circular Queue Insertion.

Circular Queue Insertion:

  • In circular queue insertion first we check whether queue is empty. If the queue is empty we show “the queue is empty ” and return.
  • In second condition we check whether the queue is empty so we insert the value in first Index.
  • In 3rd condition if Rear is in last index so we shift the rear on next index because it,s a circular queue.
  • In next condition we check space is available in queue and we increment in Rear and insert the value.

 

Algorithm:

CQInsertion(Queue,N,F,R,Value)
(1) [Start]
(2) [Check For Full]
If F=0 AND R=N-1 OR R+1=F Then
Show “ Queue is Full”
Return
Else If R= -1 Then’
F=R=0
Else If R= N -1 Then
R=0
Else
R=R+1
[End Of If Else step 2]
Queue [R]=Value
(3) [Return]

Leave a Reply

Your email address will not be published. Required fields are marked *