7.RecRelIter - Recurrence Relations In analyzing the Towers...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Recurrence Relations In analyzing the Towers of Hanoi, we might want to know how many moves it will take. Let T(n) stand for the number of moves it takes to solve the Towers problem for n disks. Then, we have the following formula: T(n) = T(n-1) + 1 + T(n-1) This is because in order to move a tower of n disks, we first move a tower of n-1 disks, which takes T(n-1) moves. Then we move the bottom disk (this is the +1 above), and then we move a tower of n-1 disks again, which takes us T(n-1) moves again. Simplifying, we get: T(n) = 2T(n-1) + 1 Unfortunately, this isn’t terribly helpful to us, because it’s not a formula in terms of n. To get a formula in terms of n, we will use the iteration technique, which simply utilizes the fact that the formula above is true for all positive integers n. We will also use the fact that T(1) = 1, since it takes one move to move a tower of one disk.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Iterating to Solve the Recurrence T(n) = 2T(n-1) + 1 = 2[2T(n-2) + 1] + 1, because T(n-1) = 2T(n-2) + 1. = 4T(n-2) + 2 + 1
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

7.RecRelIter - Recurrence Relations In analyzing the Towers...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online