GateAI
Recursion

GATE CSE 2012 · Q16

MCQ1 markEasy

Time

The recurrence relation capturing the optimal execution time of the Towers of Hanoi problem with nn discs is

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: D) T(n) = 2T(n - 1) + 1

Recursion

To solve the Towers of Hanoi problem with nn discs:

  1. Move the top n−1n-1 discs from the source peg to the auxiliary peg: takes T(n−1)T(n-1) moves.

  2. Move the largest disc from the source peg to the target peg: takes 11 move.

  3. Move the n−1n-1 discs from the auxiliary peg to the target peg: takes T(n−1)T(n-1) moves.

Summing these moves gives the total time:

T(n)=T(n−1)+1+T(n−1)=2T(n−1)+1T(n) = T(n-1) + 1 + T(n-1) = 2T(n-1) + 1

with the base condition T(1)=1T(1) = 1.

Hence, the correct recurrence is D.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

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

Where do you stand for GATE?

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.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Recursion in GATE CSE

GATE CSE 2012 Q16 is the only Recursion question in the GATE CSE papers so far.

How GATE tests Recursion

More from GATE CSE 2012

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2012 · Q16 · MCQ

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

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.