1. Let T (n) be the number of moves in our solution to the n-disc Towers of Hanoi puzzle. Recall that to solve this puzzle, •move the top n −1 discs from the source to the scratch peg, •move disc n from the source to the destination peg, and •move the top n −1 discs from the scratch to the destination peg. The first step takes T (n −1) moves, the second step takes one move, and the third step takes T (n −1) moves again. In other words, T (n) = 2T (n −1) + 1. This applies when n > 0. At zero, we have T (0) = 0, because with zero discs the start and final states are identical; there are no moves to make. Your task is to find a closed-form expression for T (n) (i.e., one that does not use recursion), and prove that it’s correct using induction.
1. Let T (n) be the number of moves in our solution to the n-disc Towers of
Hanoi puzzle. Recall that to solve this puzzle,
•move the top n −1 discs from the source to the scratch peg,
•move disc n from the source to the destination peg, and
•move the top n −1 discs from the scratch to the destination peg.
The first step takes T (n −1) moves, the second step takes one move, and
the third step takes T (n −1) moves again. In other words,
T (n) = 2T (n −1) + 1.
This applies when n > 0. At zero, we have T (0) = 0, because with zero
discs the start and final states are identical; there are no moves to make.
Your task is to find a closed-form expression for T (n) (i.e., one that does
not use recursion), and prove that it’s correct using induction.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps