After the following sequence of operations, what will be the order of elements removed from a queue?
ENQUEUE(2)
ENQUEUE(4)
ENQUEUE(8)
DEQUEUE()
ENQUEUE(10)
DEQUEUE()
After the following sequence of operations, what will be the order of elements removed from a queue?
ENQUEUE(2)
ENQUEUE(4)
ENQUEUE(8)
DEQUEUE()
ENQUEUE(10)
DEQUEUE()
Solution
✅ Correct Option: 2
A queue follows FIFO (First In, First Out), so elements leave in the same order they entered.
| Operation | Queue (front to rear) | Removed |
|---|---|---|
| ENQUEUE(2) | 2 | - |
| ENQUEUE(4) | 2, 4 | - |
| ENQUEUE(8) | 2, 4, 8 | - |
| DEQUEUE() | 4, 8 | 2 |
| ENQUEUE(10) | 4, 8, 10 | - |
| DEQUEUE() | 8, 10 | 4 |
The elements removed, in order, are 2, 4.
Options 1, 3 and 4: these take the most recently added items (LIFO, as in a stack), but a queue always removes from the front. 8 and 10 are still in the queue at the end.
Related questions:
2026: 11 May Shift 2
2025: 21 May Shift 1
2026: 31 May Shift 1
2026: 13 May Shift 2
