Concrete Mathematics - Recurrent Problems - (2)

Chapter One: Recurrent Problems

Warmups

2. Find the shortest sequence of moves that transfers a tower of n disks from the left peg A to the right peg B, if direct moves between A and B are disallowed. (Each move must be to or from the middle peg. As uaual, a large disk must never appear above a smaller one.)

This is an interest generation of "the Hanno Tower" problem. In "the Hanno Tower" problem, there are A, C, B three pegs. Originally there are n disks of different sizes in ascending order in peg A. The question is how many steps at least to move all disks from A to B, with the restriction that a large disk must never appear above a smaller one. In the problem above, there is another restriction here: direct moves between A and B are disallowed. 

Actually, we can follow the path to solve the original "Hanno Tower" problem. The steps as bellow:

1) First, we need to move the n-1 above disks from A to B with the restrictions. Mark the number of moves during this step is f(n-1).

2) Then move the nth disk in the bottom from A to C, the number of move is 1.

3) Then move the n-1 disks from B to A with the restrictions. The number of moves during this step is still f(n-1).

4) Then move the nth disk from C to B, the number of move is 1.

5) Then move the n-1 disks from A to B with the restrictions. The number of moves during this step is still f(n-1).

The above steps form the shortest sequence of moves already, and the number of moves is total f(n)=3f(n-1)+2.

How to solve the recurrent equation: f(n)=3f(n-1)+2? 

A little trick is that: f(n)+1=3(f(n-1)+1), let g(n)=f(n)+1, we have g(n)=3g(n-1). Since f(1)=2, g(1)=3, Now with the mathematics learned from high school, we have g(n)=3^n, and f(n)=3^(n)-1.


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章