The recurrence relation capturing the optimal execution time of the Towers of Hanoi problem with n discs is
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2012 · Q16
Time
Select one answerSingle correct
Solution
Official answer: D) T(n) = 2T(n - 1) + 1
RecursionTo solve the Towers of Hanoi problem with discs:
Move the top discs from the source peg to the auxiliary peg: takes moves.
Move the largest disc from the source peg to the target peg: takes move.
Move the discs from the auxiliary peg to the target peg: takes moves.
Summing these moves gives the total time:
with the base condition .
Hence, the correct recurrence is D.
Try the question first, then check your work.
Examiner trap
Moving discs requires moving discs twice (to and from the auxiliary peg) plus one move for the largest disc.
This Recursion previous year question is Q16 of the GATE CSE 2012 paper. Find more GATE CSE PYQs on Recursion in Algorithms, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 1 related Recursion PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
GATE CSE 2012 Q16 is the only Recursion question in the GATE CSE papers so far.
How GATE tests RecursionIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.