Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Disc 1

Disc 2
Disc 3

ROD 1 ROD 2 ROD 3


Steps in solving the Tower of Hanoi (3 Discs):
1. Move Disc 1 to Rod 3
2. Move Disc 2 to Rod 2
3. Move Disc 1 to Rod 2
4. Move Disc 3 to Rod 3
5. Move Disc 1 to Rod 1
6. Move Disc 2 to Rod 3
7. Move Disc 1 to Rod 3

 In solving the Tower of Hanoi in 3-disc, it takes 7 moves to reach rod 3 or


the destination.
 It has a recursive pattern.
 The number of moves of needed to transfer n disks from rod A to C is 2M +
1 where M is the number ofmoves needed to transfer n disk.
 For 3 disk, it will take 7 moves : 2M + 1 = 2(3) + 1 = 7
 Likewise, the powers fo two can help reveal the pattern : 23 – 1
 So the formula that we can use for getting the number of steps is 2n – 1.

 2n – 1 = 7 (number of moves and steps to complete)


23 – 1 = 7 (n = number of discs = 3)
8–1=7
7=7

ROD 1 ROD 2 ROD 3

STEP 1 DISC 1

STEP 2 DISC 2

STEP 3 DISC 1

STEP 4 DISC 3

STEP 5 DISC 1

STEP 6 DISC 2

STEP 7 DISC 1
Steps in solving the Tower of Hanoi (4 Discs):
1. Move Disk 1 to Rod 2 9. Move Disk 1 to Rod 3
2. Move Disk 2 to Rod 3 10. Move Disk 2 to Rod 1
3. Move Disk 1 to Rod 3 11. Move Disk 1 to Rod 1
4. Move Disk 3 to Rod 2 12. Move Disk 3 to Rod 3
5. Move Disk 1 to Rod 1 13. Move Disk 1 to Rod 2
6. Move Disk 2 to Rod 2 14. Move Disk 2 to Rod 3
7. Move Disk 1 to Rod 2 15. Move Disk 1 to Rod 3
8. Move Disk 3 to Rod 3
 In solving the Tower of Hanoi in 4-disc, it takes 15 moves to reach rod 3 or the
destination.
 It has a recursive pattern where it uses information from one step to find another,
likewise in moving the n disks from rod A to C.
 The number of moves of needed to transfer n disks from rod A to C is 2M + 1 where
M is the number ofmoves needed to transfer n disk.
 For 4 disk, it will take 15 moves : 2M + 1 = 2(7) + 1 = 15 *(7 came from the number
of steps needed in disc 3)
 Likewise, the powers fo two can help reveal the pattern : 24 – 1
 So the formula that we can use for getting the number of steps is 2n – 1.

 2n – 1 = 15 (number of moves and steps to complete)


24 – 1 = 15 (n = number of discs = 4)
16 – 1 = 15
15 = 15
ROD 1 ROD 2 ROD 3
STEP 1 D1
STEP 2 D2
STEP 3 D1
STEP 4 D3
STEP 5 D1
STEP 6 D2
STEP 7 D1
STEP 8 D3
STEP 9 D1
STEP 10 D2
STEP 11 D1
STEP 12 D3
STEP 13 D1
STEP 14 D2
STEP 15 D1

You might also like