1.

Write an algorithm to insert an element into a queue.

Answer»

Step 1: if REAR >= N -1 then
Print “Queue is overflow”
Exit
End of if
Step 2: REAR = REAR+ 1
Step 3: QUEUE [REAR] = element
Step 4: if FRONT =-1 then
FRONT = 0.



Discussion

No Comment Found

Related InterviewSolutions