GATE DA 2024, Q.32: Final value after deque operations
The question
Starting from an empty double-ended queue: insertFirst(10), insertLast(32), a ← removeFirst(), insertLast(28), insertLast(17), a ← removeFirst(), a ← removeLast(). What is the final value of a?
Watch it solved
Solve it step by step
- After inserts. [10, 32].
- removeFirst. a = 10, deque [32].
- Two insertLasts. [32, 28, 17].
- removeFirst then removeLast. a = 32, then a = 17. Final a = 17.
Answer: 17
Official IISc Bengaluru answer key: 17.
Common mistake. Losing track of which end each operation uses; draw the deque after every step.
Remember. Trace a deque as a row with two open ends and update it after each call.
Want every question solved? The past-paper pack has all 195 questions from 2024, 2025 and 2026 for ₹499. The cheat sheet pack has 23 printable sheets for ₹399.
See the past-paper pack See the cheat sheetsSource: official GATE DA 2024 question paper and answer key (IISc Bengaluru). The question is lightly reworded; every number and option is kept.