GATE CSE 2022 Q62: Minimum enqueues on Q1 to reverse its elements into Q2
- Programming and Data Structures
- 2 marks
- NAT
- No negative marking
Question
Consider the queues containing four elements and containing none (shown as the Initial State in the figure). The only operations allowed on these two queues are Enqueue(Q,element) and Dequeue(Q). The minimum number of Enqueue operations on required to place the elements of in in reverse order (shown as the Final State in the figure) without using any additional storage is___________.

Try it: numerical answer: type the value
Show answer and explanation
Answer: 0 (official GATE 2022 final answer key)
Concept used: Only enqueues on are counted; itself can be rotated (dequeue then enqueue into ) to place each new element at its front.
First step: Move 1 into ; move 2 in and rotate once so 2 is at the head; continue with 3 and 4.
Full step-by-step solution
Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.
Share this question
Source: official GATE 2022 CS question paper and final answer key, organised by IIT Kharagpur. Question paper · Answer key
More Programming and Data Structures PYQs
- 2026 Session 1 · Q23Non-leaf indices in a 1-indexed binary heap with n odd
- 2026 Session 1 · Q24Empty slots after linear-probing inserts with h(x) = (x+7) mod 11
- 2026 Session 1 · Q33Maximum height of a full binary tree with 23 nodes
- 2026 Session 1 · Q34Output of a C function with a shadowed block variable
- 2026 Session 1 · Q39Recursive length of a non-empty singly linked list
- 2026 Session 1 · Q40Third insertion that can never yield a complete BST of 1..15