Select the correct value of 'front' and 'rear' in the given queue after performing the listed operations. Consider size of the Queue as 10.
Queue:
1 2 3 4 5
Operation:
Enqueue(6), Dequeue(), Enqueue(7), Dequeue(), Dequeue()
Select the correct value of 'front' and 'rear' in the given queue after performing the listed operations. Consider size of the Queue as 10.
Queue:
| 1 | 2 | 3 | 4 | 5 |
|---|
Operation:
Enqueue(6), Dequeue(), Enqueue(7), Dequeue(), Dequeue()
Solution
✅ Correct Option: 2
A queue is first in, first out: Enqueue adds at the rear, and Dequeue removes from the front.
| Operation | Queue after it | Front | Rear |
|---|---|---|---|
| Start | 1, 2, 3, 4, 5 | 1 | 5 |
| Enqueue(6) | 1, 2, 3, 4, 5, 6 | 1 | 6 |
| Dequeue() | 2, 3, 4, 5, 6 | 2 | 6 |
| Enqueue(7) | 2, 3, 4, 5, 6, 7 | 2 | 7 |
| Dequeue() | 3, 4, 5, 6, 7 | 3 | 7 |
| Dequeue() | 4, 5, 6, 7 | 4 | 7 |
Option 1: front=3 is the value after only two Dequeue() operations, but there are three.
Option 3: rear=6 ignores Enqueue(7).
Option 4: front=2 is the value after only one Dequeue().
Related questions:
2026: 29 May Shift 2
2025: 3 June Shift 2