Professional Documents
Culture Documents
Queue is ordered collection of homogeneous data elements in which insertion and deletion
operation take place at two end . insertion allowed from starting of queue called FRONT point
and deletion allowed from REAR end only
Conditions in Queue
Restriction in Queue
we can not insert element directly at middle index (position) in Queue and vice verse for
deletion. insertion operation possible at REAR end only and deletion operation at FRONT end,
to insert we increment REAR and to delete we increment FRONT.
REAR.
Steps:
1. If ( REAR = size ) then //Queue is full
2.
print "Queue is full"
3.
Exit
4. Else
5.
If ( FRONT = 0 ) and ( REAR = 0 ) then //Queue is empty
6.
FRONT = 1
7.
End if
8.
REAR = REAR + 1 // increment REAR
9.
Que[ REAR ] = ITEM
10. End if
11. Stop
Steps:
1. If ( FRONT = 0 ) then
2.
print "Queue is empty"
3.
Exit
4. Else
5.
ITEM = Que [ FRONT ]
6.
If ( FRONT = REAR )
7.
REAR = 0
8.
FRONT = 0
9.
Else
10.
FRONT = FRONT + 1
11.
End if
12. End if
13. Stop