Question
The recurrence relation capturing the optimal execution time of the Towers of Hanoi problem with discs is
Official answer and solution
- Official answer
- D
- From
- Official GATE 2012 answer key
Solution
Formulate the recurrence relation for moving disks between three pegs in the classic Towers of Hanoi puzzle.
- To transfer disks from the source peg to the target peg using auxiliary peg :
- Step 1: Recursively move the top disks from peg to peg . This requires optimal moves.
- Step 2: Move the single largest disk (-th disk) directly from peg to peg . This takes exactly 1 move.
- Step 3: Recursively move the disks from peg to peg using peg . This requires optimal moves.
- Summing the moves gives the recurrence relation:
with base condition .
- Solving this recurrence yields , confirming option (D).
Final answer
D
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2012 Computer Science and Information Technology (CS)
- Question
- 16 of 65, printed as CS Q.16
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.