Question:

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:
\(F→50 → 90 → 7 → 21 → 73 → 77→R\)
dequeue()
dequeue()
dequeue()
dequeue()
dequeue()
enqueue(100)
dequeue()

Updated On: Mar 28, 2025
  • Front 50, Rear 77
  • Front 100, Rear 100
  • Front 77, Rear 100
  • Front 73, Rear 77
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

The final positions of front and rear after executing the queue operations will be Front 77, Rear 100.

Additional Context:

  • Initial Queue State:
    • Front (F) → 50
    • Rear (R) → 77
    • Order: 50 → 90 → 7 → 21 → 73 → 77
  • Operation Breakdown:
    1. dequeue() → Remove 50 → Queue: 90 → 7 → 21 → 73 → 77
    2. dequeue() → Remove 90 → Queue: 7 → 21 → 73 → 77
    3. dequeue() → Remove 7 → Queue: 21 → 73 → 77
    4. dequeue() → Remove 21 → Queue: 73 → 77
    5. enqueue(100) → Add 100 → Queue: 73 → 77 → 100
    6. dequeue() → Remove 73 → Queue: 77 → 100
  • Final State:
    • Front points to 77 (next to dequeue)
    • Rear points to 100 (last added)
  • Queue Properties:
    • FIFO (First-In-First-Out) structure
    • enqueue adds to rear, dequeue removes from front

Correct Answer: (3) Front 77, Rear 100.

Was this answer helpful?
0
0