Consider an initially empty queue. Which of the following elements will be present in the queue after the execution of the following operations?
enqueue(a)
enqueue(b)
enqueue(c)
dequeue()
enqueue(d)
dequeue()
dequeue()
A. a
B. b
C. c
D. d
Consider an initially empty queue. Which of the following elements will be present in the queue after the execution of the following operations?
enqueue(a)
enqueue(b)
enqueue(c)
dequeue()
enqueue(d)
dequeue()
dequeue()
A. a
B. b
C. c
D. d
Solution
✅ Correct Option: 1
A queue is FIFO (first in, first out), so each dequeue removes the oldest element.
| Operation | Queue (front to rear) |
|---|---|
| enqueue(a) | a |
| enqueue(b) | a, b |
| enqueue(c) | a, b, c |
| dequeue() removes a | b, c |
| enqueue(d) | b, c, d |
| dequeue() removes b | c, d |
| dequeue() removes c | d |
Only d remains.
Option 2 (A only): a is the first element enqueued, so it is the first one removed. It is not the one left.
Option 4 (B and C only): this would be the result if d were never enqueued and only one dequeue ran. Here three dequeues remove a, b and c.
Related questions:
2025: 30 May Shift 2
2025: 21 May Shift 1
2026: 18 May Shift 2
2026: 23 May Shift 2