Procedure: QINSERT_REAR (Q, F, R, N,Y)
Given F and R pointers to the front and rear elements of a queue respectively. Queue Q consisting of N elements. This procedure inserts Y at rear end of Queue.
1. [Overflow]
IF R >= N
Then write (‘OVERFLOW’)
Return
2. [Increment REAR pointer]
R<- R + 1
3. [Insert element ]
Q[R] <- Y
4. [Is front pointer properly set]
IF F=0
Then F <- 1
Return
Function: QDELETE_FRONT (Q, F, R)
Given F and R pointers to the front and rear elements of a queue respectively. Queue Q consisting of N elements. This function deleted and element from front end of the Queue.
1. [Underflow]
IF F= 0
Then write (‘UNDERFLOW’)
Return(0) (0 denotes an empty Queue)
2. [Decrement element]
Y<- Q[F]
3. [Queue empty?]
IF F=R
Then F<- R<- 0
Else F<- F+1 (increment front pointer)
4. [Return element]
Return (Y)