Write an algorithm of priority linear queue insertion.

priority linear queue insertion:

  • In a priority queue each element has it,s priority.
  • In first step we check if the rear is full so we can,not insert the element in queue.
  • In second step we check if queue is empty so we insert the element in first index(0).
  • In third step we increment in rear it means space is available in queue
  • And insert the element using its priority.

Algorithm:

PLQInsertion(Queue,N,F,R,Value,P)
(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 [P][R]=Value
(3) [Return]

Leave a Reply

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