Hanoi pass Formula Proof:
Set three towers for a, B, C, respectively. When a tower has n plates initially, it needs T (n) steps to transfer to Tower C.
First, there are the following rules:
T (0) = 0 (of course 0 when there is no plate)
T (1) = 1
T (2) = 3
T (3) = 7
... /p>
T (n) = t (n-1) + 1 + t (n-1) = (n-1) + 1
Why t (n) = 2 * t (n-1) + 1?
It is easy to think that when n = n-1,
(1) The number of steps required to move all plates from tower A to Tower C is T (n-1).
(2) If the number of steps moved from a to C is T (n-1), then moving from A to B also requires T (n-1)
So when n = N:
(1) First move all trays of a tower to Tower B, need t (n -1 Step
(2) moves the last plate of tower A to tower C, which requires 1 steps
(3) to move all trays of Tower B to tower C, requiring t (n -1) steps. The
Final result requires a T (n -1) + 1 step.
So T (n) = 2 * t (n -1) + 1
What is the general formula? How do you prove it?
is simple ~
To add 1 to both ends of the equation:
T (n) + 1 = 2 * (t (n-1) + 1)
Set T (n) + 1 = S (n)
Then: s (n) = 2 *s (n-1)
And when n = 1, S (1) = 1;
Then s (n) = 2 ^ n
So: T (n) + 1 = S (n) = 2 ^ n
That is T (n) = 2 ^ n-1
The
is completed.
Hanoi formula derivation