What will be the front of the QUEUE after following operations are performed on the elements of the list [4, 5, 12, 21, 14, 6, 8, 10, 18]?
enqueue
enqueue
dequeue
enqueue
enqueue
enqueue
dequeue
dequeue
What will be the front of the QUEUE after following operations are performed on the elements of the list [4, 5, 12, 21, 14, 6, 8, 10, 18]?
enqueue
enqueue
dequeue
enqueue
enqueue
enqueue
dequeue
dequeue
Solution
✅ Correct Option: 1
A queue is FIFO (first in, first out). Each enqueue adds the next element of the list at the rear, and each dequeue removes the element at the front.
| Operation | Queue (front on the left) |
|---|---|
| enqueue | 4 |
| enqueue | 4, 5 |
| dequeue (removes 4) | 5 |
| enqueue | 5, 12 |
| enqueue | 5, 12, 21 |
| enqueue | 5, 12, 21, 14 |
| dequeue (removes 5) | 12, 21, 14 |
| dequeue (removes 12) | 21, 14 |
The front element is 21.
Related questions:
2025: 22 May Shift 1
2025: 27 May Shift 2
2025: 16 May Shift 1
2025: 30 May Shift 2
2025: 15 May Shift 2
2025: 3 June Shift 2