开发者

Hanoi specific problem

开发者 https://www.devze.com 2023-02-01 17:10 出处:网络
Suppose that there are 2*n disks, How could be Hanoi problem solved if odd numbers are disks on bar \"A\" and even disks are on bar \"B\"?

Suppose that there are 2*n disks, How could be Hanoi problem solved if odd numbers are disks on bar "A" and even disks are on bar "B"? please Let me know 开发者_如何学编程if more information is needed.

Thanks


move disk 1 onto disk 2 then move the resulting "proper" hanoi towner 1,2 onto disk 3 using the classic algorithm. Then move the proper tower 1,2,3 onto 4. Continue until you get the full proper tower, then use classic algorithm to move to the destination.

EDIT1:

Example (incomplete)

1   2
3   4
5   6   
.   .   .

    1
    2
3   4
5   6   
.   .   .

    1
    2
    4
5   6   3
.   .   .

    2
1   4   
5   6   3
.   .   .

1   4   2   
5   6   3
.   .   .

        1
    4   2   
5   6   3
.   .   .

        1
4       2   
5   6   3
.   .   .

This is curious because the last step is a little bit of an optimization; what I described would try to build 1-2-3-4-6 but we jump directly to building 1-2-3-4-5. This probably means something.

0

精彩评论

暂无评论...
验证码 换一张
取 消