0% found this document useful (0 votes)
6 views6 pages

Module7 - Students

Uploaded by

Rejean Fabria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

Module7 - Students

Uploaded by

Rejean Fabria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Module 7

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

• Mowing the lawn is a problem that demonstrates linear complexity.


• If you double the size of the area that you want to mow, it will take twice
as long to complete the task.

More Complex Problems

• 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.

How many moves does it take?

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

The number of moves increases significantly as more disks are added.


In mathematics the phrase exponential growth is used to describe the increase in the number of
moves required to solve the problem in relation to the number of disks

If the legend of the Vietnamese


or Indian temple were true, and
if the priests were able to move
disks at a rate of one per second,
using the smallest number
of moves, it would take them
roughly 272 thousand years to
complete.

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.

Remember it takes (2n-1) moves where n=number of disks.

Number of Moves Required


Number of Disks
to Solve the Problem
6 63
9 511
15
25
1,099,511,627,775
64 9,223,372,036,854,775,808

 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.

The Travelling Salesman Problem

• For a given set of cities, visit each city once and minimise the distance you travel.
• Explore the puzzle http://www.tinyurl.com/salesman1

How many possible routes?

• Remember it takes (n-1)! moves where n=number of cities


• E.G. For 10 cities (n-1)! = (10-1)! = 9! = 9x8x7x6x5x4x3x2x1

Number of Cities Number of Possible Routes


10 362, 880
12 39,916,800
15 87,178,291,200
25 620,448,401,733,239,439,360,000

How much time does it take?

• 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.

Number of Cities Number of Possible Routes


10 0.36 seconds
12 39.91 seconds
15 24.21 hours
25 196 billion years

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

You might also like