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.


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值