1 / 74

On Optimal Solutions for the Bottleneck Tower of Hanoi Problem

On Optimal Solutions for the Bottleneck Tower of Hanoi Problem . Yefim Dinitz Shay Solomon Dept. of Comp. Sci., Ben-Gurion University ISRAEL. Contents of the lecture. 1. Background on the Tower of Hanoi. 2. The Bottleneck Tower of Hanoi (BTH) problem.

fergal
Download Presentation

On Optimal Solutions for the Bottleneck Tower of Hanoi Problem

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. On Optimal Solutions for the Bottleneck Tower of Hanoi Problem Yefim Dinitz Shay Solomon Dept. of Comp. Sci., Ben-Gurion University ISRAEL

  2. Contents of the lecture 1. Background on the Tower of Hanoi. 2. The Bottleneck Tower of Hanoi (BTH) problem. 3. The family of all optimal solutions to BTH. 4. Investigation of the configuration graph of BTH: its diameter and average distance.

  3. 1. Background • The first version of the puzzle was marketed by Edouard Lucas in 1883, under the name "Tower of Hanoi“: - Given are 3 pegs, denoted by A,B and C, and ndisks of distinct sizes placed on peg A in decreasing order, largest at the bottom to the smallest at the top. - The goal of the puzzle is to transfer all disksto peg C, placed in the same order, by the minimum possible number of moves. - The rules are to move a single disk from (the top of) one peg to (the top of) another one at each step, following the "divine rule": to never have a larger disk above a smaller one.

  4. Move number Example for general n 1 2 … … … n-1 n A B C

  5. Move number Cn-1 The optimal transfer for general n 1 2 … … … n-1 n A B C

  6. Move number Cn-1 + 1 The optimal transfer for general n 1 2 … … … n-1 n A B C

  7. Move number 2 Cn-1 + 1 The optimal transfer for general n 1 2 … … … n-1 n A B C

  8. The recurrence formula is cn = 2cn-1 + 1, c1 = 1. Hence,cn = 2^n -1. This classical Tower of Hanoi problem with three pegs is a basic problem, taught as a basic example of a recursion program.

  9. There is a great proliferation of new ToH puzzles posed over the last twenty years. There is a bibliography made by Paul Stockmeyer, which covers over 350 papers on the subject.

  10. 2. The Bottleneck ToH problem In 1981, D. Wood posed the following generalization of ToH, which we call the “Bottleneck Tower of Hanoi Problem, BTHn= BTHn,k”, depending on an integer parameter k, k>0.

  11. The k-relaxed Placement Rule:Besides the usual placement of smaller disks above bigger ones, a bigger disk j may be placed above a smaller disk i, if their size difference j - i < k. i+k …. …. i

  12. Definitions • A placement of the n disks [1..n] on a single peg is called a tower of n disks. • The decreasing bottom-top placement of the n disks [1..n] on a peg is called the perfect tower. 1 2 3 … … n-2 n-1 n

  13. Description of BTHn: • There are 3 pegs: A,B, and C. • The goal is to transfer the perfect toweron peg A to the perfect toweron peg C. • The placement rule is k-relaxed. (Note that if k=1, we arrive at the classical problem.)

  14. Example: k=4, n=7 We note that there are many legal towers for a given k. As k grows, there are morelegal towers. 1 2 3 7 6 5 4 (The two extreme) examples: k=1, one legal tower (perfect tower). k≥n, n!possible towers. Legal

  15. D.Poole [1992] suggested the sequence of moves αn (described in the next slide), which solves BTHn. He showed its optimality within just one simple strategy. • Beneditkis, Berend, and Safro[1998]proved its optimalityfor the case k=2. • We proved optimality of αn for the general case [ISAAC’2006]. • Remark: another proof of optimality ofαn for BTHn, by different techniques, was suggested independently by Xiaomin Chen et al. (unpublished).

  16. αn(A,C) (not explicitly) 1.(*) Move disks [1..(n-1)] from A, by the minimum possible number of moves, to any (legal) state on B. 2. Move disk n from A to C. 3.(*) Move disks [1..(n-1)] from B to the perfect tower on C, by the minimum possible number of moves.

  17. 1 2 3 4 …. …. …. …. …. n-1 n B C A

  18. [1..n-1] n B C A

  19. [1..n-1] n B C A

  20. 1 2 3 4 …. …. …. …. …. n-1 n B C A

  21. “Somehow” tower-move(*):To move a tower of m disks on one peg, to a tower of m disks on another peg, in anyorder. • D. Poole and BBS used, for the “somehow” problem, the following optimal sequence of moves, βm:

  22. βm(source,target):(for the explanation, assume that the initial configuration is perfect) • If m ≤ k, move all disks from source to target one by one. • Otherwise: 1.Recursively perform βm-k(source,auxiliary). 2. Move k disks [(m-k+1)..m] one by one fromsource to target. 3. Recursively perform βm-k(auxiliary,target).

  23. K=4, m=7 1 2 3 4 5 6 7 source auxiliary target

  24. 4 5 6 7 3 2 1 source auxiliary target

  25. 7 6 5 4 3 2 1 source auxiliary target

  26. 1 2 3 7 6 5 4 source auxiliary target

  27. K=4, m=11 1 2 3 4 5 6 7 8 9 10 11 source auxiliary target

  28. 8 9 10 11 1 2 3 7 6 5 4 source auxiliary target

  29. 11 10 9 8 1 2 3 7 6 5 4 source auxiliary target

  30. 1 2 3 4 5 6 7 11 10 9 8 source auxiliary target

  31. (**) We remark that, if we start with the perfect tower on A, and perform βm(A,B)followed byβm(B,C), the result is the perfect tower on C.

  32. αn(A,C), reformulated 1. perform βn-1(A,B). 2. Move disk n from A to C. 3. perform βn-1(B,C). By earlier remark (**), αnsolves BTHn.

  33. 1 2 3 4 …. …. …. …. …. n-1 n B C A

  34. 1 2 3 …. …. n-k-1 n-1 …. n-k+1 n-k n B C A

  35. 1 2 3 …. …. n-k-1 n-1 …. n-k+1 n-k n B C A

  36. 1 2 3 4 …. …. …. …. …. n-1 n B C A

  37. Notation and numerical results • bm = The number of moves in βm • an = The number of moves in αn • bm = 2bm-k + k ; b1 = 1,…, bk = k. bm = r (2^q) + k (2^q -1), where m = qk +r. • an = 2bn-1 + 1 ; a1 = 1. an = r (2^(q+1)) + k (2^(q+1) -2) + 1, where n-1=qk + r.

  38. 3. Family of all optimal solutions toBTHn We provethat, in any optimal solution toBTHn, disk n makes only one move, from peg A to C. Before that move, all disks 1,…,n-1 have been moved from peg A to peg B. After that move, all disks 1,..,n-1 willmove from peg B to peg C.

  39. Is αn the unique optimal solution? In the casek=1, the answer is yes (and is well known): there exists a unique solution for the classical problem. For the case k ≥ 2, the answer is No! Let us see a different sequence of moves, of the same length as that of αn:

  40. Example n=10, k=3 1 2 3 4 5 6 7 8 9 10 A B C

  41. 4 5 6 7 8 9 10 3 2 1 A B C

  42. 7 8 9 10 3 2 1 6 5 4 A B C

  43. 1 2 3 6 5 4 7 8 9 10 A B C

  44. 1 2 3 6 5 4 9 8 7 10 A B C

  45. Until this point, the move-sequence is the same asαn 6 5 4 3 2 1 10 9 8 7 A B C

  46. 5 4 3 6 9 8 7 2 1 10 A B C

  47. 2 5 3 6 9 8 7 4 1 10 A B C

  48. 1 4 2 5 3 6 9 8 7 10 A B C

  49. 1 4 2 5 3 6 9 8 7 10 A B C

  50. 9 8 7 3 2 1 10 6 5 4 A B C

More Related