*Season 3* • *Episode 18* • *The Tower of Hanoi*

^{0}

## The Tower of Hanoi

### Season 3

### Episode 18 Time frame 2 periods

### Prerequisites :

Introdutiontoproofbyindution.### Objectives :

### •

^{Understand}

^{the}

^{usefulness}

^{of}

^{indution}

^{in}algorithms.

### Materials :

### •

^{Cardboard}

^{towers}

^{of}

^{Hanoi.}

### •

^{Beamer.}

### •

^{Wooden}

^{tower}

^{of}

^{Hanoi.}

## 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:

### •

^{Where}

^{to}

^{move}

^{the}

^{rst}

^{disk}

^{?}

### •

^{Is}

^{it}

^{possible}

^{to}

^{desribe}

^{a}

^{simple}

^{algorithm}

^{solving}

^{the}

^{puzzle}

^{?}

### •

^{What}

^{is}

^{the}

^{lowest}

^{possible}

^{number}

^{of}

^{moves}

^{for}

^{a}

### n

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

^{and}

### n = 4

^{.}

^{Relation}

^{with}

^{the}

^{Sierpinski}

^{triangle}

## The 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:

### •

^{Only}

^{one}

^{disk}

^{may}

^{be}

^{moved}

^{at}

^{a}

^{time.}

### •

^{Eah}

^{move}

^{onsists}

^{of}

^{taking}

^{the}

^{upper}

^{disk}

^{from}

^{one}

^{of}

^{the}

^{posts}

^{and}

^{sliding}

^{it}

^{onto}

^{another}

^{post,}

^{on}

topoftheotherdisksthatmayalreadybepresentonthat post.

### •

^{No}

^{disk}

^{may}

^{be}

^{plaed}

^{on}

^{top}

^{of}

^{a}

^{smaller}

^{disk.}

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,}

^{the}

^{lowest}

^{number}

^{of}

^{moves}

^{is}

^{obviously}

### 1 = 2 ^{1} − 1

^{,}

sothepropertyistrue.

Indutive step: Then, suppose that we have proved the lowest number of moves needed to move a

### k

disks toweris### 2 ^{k} −

^{,}

^{for}

^{a}

^{natural}

^{number}

### k

. Let'slook at the### k + 1

^{disks}

^{tower.}

^{To}

^{move}

^{it}

^{to}

thedestination 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 the### k

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

^{disks}

^{tower.}

Conlusion : Sineboththebasisandtheindutivestephavebeenproved,ithasnowbeenprovedby

mathematialindution thatthepropertyholdsforallnatural

### n

.## The end of the world

Ifthelegendweretrue,andifthepriestswereabletomovedisksat arateofoneperseond,usingthe

smallestnumberofmoves,it would takethem

### 2 ^{64} − 1

^{seonds}

^{or}

^{roughly}

^{600}

^{billion}

^{years}

^{to}

^{move}

^{the}

*Season 3* • *Episode 18* • *The Tower of Hanoi*

^{2}

## Document 1

^{Cardboard}

^{towers}

^{of}

^{Hanoi}