Solveeit Logo

Question

Computer Science Question on Introduction to Queue (FIFO)

What will be the position of front and rear after execution of the following statements, the Queue already had the given elements in FIFO order:
F50907217377RF→50 → 90 → 7 → 21 → 73 → 77→R
dequeue()
dequeue()
dequeue()
dequeue()
dequeue()
enqueue(100)
dequeue()

A

Front 50, Rear 77

B

Front 100, Rear 100

C

Front 77, Rear 100

D

Front 73, Rear 77

Answer

Front 77, Rear 100

Explanation

Solution

After five dequeue() operations, the queue becomes empty. enqueue(100) then adds to the rear, and one more dequeue() brings front to 77 and rear to 100.