Write an algorithm of linear queue Insertion.

Linear Queue Insertion:

  •  In linear queue insertion we insert the data in a sequence .
  • In linear queue we insert the data from last point and  the last index is called “Rear”.
  •  And we delete the data from the first point is called “Front”.
  • If (Rear =N-1) then queue is full. Because N is total length of queue. And queue is start        from 0 index.
  • And if rear and front are (=-1) then front and rear shift on  (0) index.
  • And if the space is available in queue then we increment in Rear. And insert the value.

 Algorithm:

LQInsertion(Queue,N,F,R,Value)
(1) [Start]
(2) [Check For Full]
If R=N-1 Then
Show “ Queue is Full”
Return
Else If R= -1 Then’
F=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 *