ProgrammingHardGATE CS · Campus placements

How many disk moves does the optimal Tower of Hanoi solution need for 5 disks?

  1. A. 15
  2. B. 31
  3. C. 32
  4. D. 25

Correct answer: B. 31

The recurrence M(n) = 2 M(n-1) + 1 with M(0) = 0 gives 2^n - 1, so M(5) = 31. Each extra disk doubles the work and adds one move.

More C Programming questions

Exams that ask this topic