Module7 - Students
Module7 - Students
Solving Complex
Problems
The Towers of Hanoi 2
Exercises 3
The Travelling Salesman Problem 4
Exercises 5
End of Module Quiz 7
© 2013 Lero
The Towers of Hanoi
Linear Complexity
• Many problems will increase in complexity very quickly each time an extra input is added.
• Explore the Towers Of Hanoi Puzzle online at http://www.tinyurl.com/hanoi1
The instructions button on the web page describes the rules of the puzzle. The goal of the towers of
Hanoi problem is to move a stack of disks from one peg to another in as few moves as possible. You may
move only one disk at a time. You may not stack larger disks on top of smaller disks.
The puzzle was invented by the French mathematician Édouard Lucas in 1883. There is a legend about a
Vietnamese or Indian temple which contains a large room with three time-worn posts surrounded by 64
golden disks. The priests of Brahma, acting out the command of an ancient prophecy, have been moving
these disks, in accordance with the rules of the puzzle. According to the legend, when the last move of
the puzzle is completed, the world will end. It is not clear whether Lucas invented this legend or was
inspired by it.
Did you know you should be able to complete the puzzle in (2n -1) moves where n is the number
of disks?
For 3 disks 2n -1= (23 – 1) = (8-1) =7 moves
2 | Scratch Workbook
Exercises
See if you can use your maths skills to complete the table below that details the growth in
complexity for the Towers of Hanoi problem.
Download the “Towers of Hanoi” Scratch Project in the resources section of Module 7
at http://www.scratch.ie/students
Once you have the project open in Scratch click on the ‘Show project notes’ button under the File
menu to view instructions for the game. Take a look at the script for the game. Then play the game
and see if you can modify the script to make improvements.
Module 7 | 3
The Travelling Salesman Problem
The Travelling Salesman Problem is one of the most intensively studied problems in computational
mathematics. These pages are devoted to the history, applications, and current research of this challenge
of finding the shortest route visiting each member of a collection of locations and returning to your
starting point.
• For a given set of cities, visit each city once and minimise the distance you travel.
• Explore the puzzle http://www.tinyurl.com/salesman1
• These calculations are based on a computer being able to execute 1 million instructions per
second.
• The problem cannot be solved in a reasonable amount of time for 25 cities. This does not
mean that the problem cannot be solved for 25 cities. Computer science researchers have
devised new approaches besides analysing all possible routes to solving the Travelling
Salesman Problem. They use optimisation and approximation techniques to find a near-
optimal solution.
4 | Scratch Workbook
Not just for The Travelling Salesman
• Although transportation applications are the most natural setting for the
Travelling Salesman Problem, the model has led to many interesting
applications in other areas.
• Used in Biology to compute DNA sequences.
• A Travelling Salesman algorithm is used to minimise the use of fuel in targeting
and imaging manoeuvres for the pair of satellites involved in NASA Starlight space
interferometer program.
Exercises
A band wishes to tour ten destinations across the Southern region of Ireland that have been
circled in the map below over two weeks during the summer to promote the release of their new
album. The tour will start and finish in Dublin. With the help of the map and the legend indicating
distances between the towns, fill the table below to indicate the shortest round trip to Dublin that
the band can take during their tour.
Module 7 | 5
6 | Scratch Workbook