Season 3 • Episode 18 • The Tower of Hanoi
0The Tower of Hanoi
Season 3
Episode 18 Time frame 2 periods
Prerequisites :
Introdutiontoproofbyindution.Objectives :
•
Understandtheusefulnessofindutioninalgorithms.Materials :
•
CardboardtowersofHanoi.•
Beamer.•
WoodentowerofHanoi.1 – Find the shortest number of moves for n ∈ { 2 , 3 , 4 }. 25 mins
Studest work in pairsorgroupsof three tond awayto movethetowertoits destination.Numberof
movesareompared.
2 – Study the movements 30 mins
Answerto thefollowingquestions:
•
Wheretomovetherstdisk?•
Is itpossibletodesribeasimplealgorithmsolvingthepuzzle?•
Whatisthelowestpossiblenumberofmovesforan
diskstower?3 – The formula for n disks 35 mins
Prove the general formula for the number of moves for the
n
disks tower. Then, use it to answer the questionfromthelegend:whenwill theend oftheworldtakeplae?4 – Graph representation 20 mins
Thegraphofallpossiblemovesisshownfor
n = 2
,n = 3
andn = 4
.RelationwiththeSierpinskitriangleThe Tower of Hanoi
Season 3
Episode 18 Document Lesson
ThepuzzlewasinventedbytheFrenhmathematiianÉdouardLuasin1883.It'sbasedonaVietnamese
orIndianlegendaboutatemplewhihontainedalargeroomwiththreetime-wornpostsinitsurrounded
by64 golden disks.The priestsof Brahma,atingouttheommand ofananientprophey,havebeen
movingthesedisksfromtherstpost tothethird,in aordanewiththefollowingrules:
•
Onlyonediskmaybemovedat atime.•
Eahmoveonsistsoftakingtheupperdiskfromoneofthepostsandslidingitontoanotherpost,ontopoftheotherdisksthatmayalreadybepresentonthat post.
•
Nodiskmaybeplaedontopofasmallerdisk.Aordingtothelegend,whenthelastmoveofthepuzzleisompleted,theworldwillend.Itisnotlear
whether Luasinventedthislegendorwasinspiredbyit.
Simple solution to the puzzle
The followingproedure yields thelowestpossiblenumberofmovesto moveanynumberof disksfrom
therstposttothethird.
Ifthenumberofdisksisodd,startbymovingthesmallestdisktothedestinationpost.Ifthe
numberofdisksiseven,startbymovingthesmallestdisk totheintermediarypost.
Then, alternate movesbetweenthe smallestpiee and a non-smallest piee. When moving
the smallestpiee, always move it in the samediretion (either to the left orto the right,
aordingtoyourrstmove,butbeonsistent).Ifthereisnotowerin thehosendiretion,
moveitto theopposite end. Whenthe turnis tomovethe non-smallestpiee,there isonly
onelegalmove.
The lowest number of moves
Theorem 1
The lowest number of moves necessary to move a n disks tower is 2 n − 1 .
Proof.Let'sprovethisresultbyindution.
Basis : First,onsider the
1
-disk situation.Then,thelowest numberof movesisobviously1 = 2 1 − 1
,sothepropertyistrue.
Indutive step: Then, suppose that we have proved the lowest number of moves needed to move a
k
disks toweris2 k −
, for anaturalnumberk
. Let'slook at thek + 1
disks tower.Tomoveit tothedestination post, we must rstmove the
k
disks at the topof the tower to theintermediary post, then move the largestdisk to the destination post, then move thek
disks tower from the intermediaryposttothedestinationpost.Aordingtoourindutionhypothesis,thetotalnumberofmovesforthisproedure is
(2 k − 1) + 1 + (2 k − 1) = 2 × 2 k − 1 = 2 k +1 − 1 .
Sothepropertyistrueforthe
k + 1
diskstower.Conlusion : Sineboththebasisandtheindutivestephavebeenproved,ithasnowbeenprovedby
mathematialindution thatthepropertyholdsforallnatural
n
.The end of the world
Ifthelegendweretrue,andifthepriestswereabletomovedisksat arateofoneperseond,usingthe
smallestnumberofmoves,it would takethem