1 / 14

The Tower of Hanoi

The Tower of Hanoi. Ben Epstein Special Topics 2003. Lucas and The Tower of Brahma Origins of The Tower of Hanoi.

bobby
Télécharger la présentation

The Tower of Hanoi

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. The Tower of Hanoi Ben Epstein Special Topics 2003

  2. Lucas and The Tower of BrahmaOrigins of The Tower of Hanoi The Tower of Hanoi puzzle was invented in 1883 by the French mathematician Edouard Lucas. A year later another French mathematician, De Parville, composed the following tale commonly associated with The Tower of Hanoi. "In the great temple at Benares, says he, beneath the dome which marks the centre of the world, rests a brass plate in which are fixed three diamond needles, each a cubit high and as thick as the body of a bee. On one of these needles, at the creation, God placed sixty-four discs of pure gold, the largest disc resting on the brass plate, and the others getting smaller and smaller up to the top one. This is the Tower of Bramah. Day and night unceasingly the priests transfer the discs from one diamond needle to another according to the fixed and immutable laws of Bramah, which require that the priest on duty must not move more than one disc at a time and that he must place this disc on a needle so that there is no smaller disc below it. When the sixty-four discs shall have been thus transferred from the needle on which at the creation God placed them to one of the other needles, tower, temple, and Bramahns alike will crumble into dust, and with a thunderclap the world will vanish." http://www.article19.com/shockwave/toh.htm

  3. How To Play • The puzzle consists of p pegs and d disks, with each disk being a different size. • The object is to relocate the entire tower to a different peg. • The stipulations are that only one disk can be moved at a time and no disk can be placed atop a smaller disk. • We will examine the puzzle when and . http://www.cut-the-knot.org/recurrence/hanoi.shtml

  4. Source Peg Auxiliary Peg Destination Peg Peg Labeling In order to explain the solutions we must distinguish between the pegs. So let the peg on which the tower sits be the source peg. Call the peg you wish to move to the destination peg. Call the peg necessary for auxiliary moves the auxiliary peg. NOTE: A new tower will be created with every move. Consequently, the pegs which we initially called the source, auxiliary and destination pegs will constantly change.

  5. d = 6 q = 63 d = 4 q = 15 d = 7 q = 127 d = 5 q = 31 d = 8 q = 255 Preliminary Observations Let q equal to the minimum number of moves necessary to complete the relocation. Examining the case when d = 3 we find q = 7. Can you see the pattern? http://www.cut-the-knot.org/recurrence/hanoi.html

  6. Observations Continued The following equation gives q for any d: This will be true for all d provided that p = 3. In the case of De Parville’s story the priests had to relocate a tower of 64 disks. Therefore:Supposing that the priests were proficient enough to make a move a second, the world would end in 584,942,417,355.1 years. http://www.cut-the-knot.org/recurrence/hanoi.html

  7. Move Sequence for d = 3 0 1 2 3 4 5 6 7

  8. More Observations • When looking at the case of d = 3 the first move must be made to the destination peg to ensure a solution with minimal q. • Similarly, for d = 4 the first move must be made to the auxiliary peg. • It will be the case that for odd d the first move must always be made to the destination peg. For even d the first move must always be made to the auxiliary peg. http://www.cut-the-knot.org/recurrence/hanoi.shtml

  9. Recurrence Relations Another way of approaching this problem is to look at the first d – 1 disks. The goal would then be to first relocate those disks to the auxiliary peg. Next one would simply move the last disk to the destination peg. Finally, the solution would be achieved by relocating the d – 1 disk tower to the destination peg. This method gives rise to the notion of recurrence.

  10. Move Sequence for d = 3 0 1 2 3 4 5 6 7

  11. Recurrence Relations Continued Consider T(d), where T(d) = q and d = 3 and q = 7. We know T(3) = 7. Using the recurrence relation we can see that In this example T(3-1) is the number of moves to relocate the top two disks. Clearly this must be done twice: once to uncover the largest disk and again to re-cover it, therefore it is multiplied by two. The “+1” comes from the single move of the largest disk from the source to destination peg. Likewise, for all d except d = 0 the following holds: NOTE: T(0) = 0

  12. Sierpinski’s Gasket http://www.cut-the-knot.com/triangle/Hanoi.shtml http://www.rci.rutgers.edu/~cfs/305_html/Computation/ProbRed_305.html

  13. Sierpinski’s Gasket Peg # 3 1 1 d1 d2 d3

  14. Class Exercises What is T(15)? Draw the move sequence for d = 4.

More Related