Toy Problems For The Real World

Tenderfoot: Unit 2
Clever Stuff For Common Problems
Going beyond simple algorithms
Toy Problems For
The Real World
Classroom Resources
CAS Tenderfoot
Minimum Spanning Tree Algorithms
Teacher Notes to support Tenderfoot Unit 2: Clever Stuff For Common Problems – Going beyond simple algorithms
This simple class activity leads to students discovering either Prim’s or Kruskal’s algorithm for finding a
Minimum Spanning Tree (MST). It goes on to consider the similarities and differences between a MST and
other classic graph traversal algorithms.
Preparation required:
Muddy City puzzle sheet for each small group
A Muddy City
This simple exploration allow pupils to discover famous
algorithms that are used today in a wide range of real world
problems. Split into small groups and distribute the map.
Explain that it has no roads, making it difficult (and muddy) to
get around. Enough streets must be paved so it is possible to
travel from any house to any other house, possibly via other
houses. The paving should be done at a minimum cost. The
diagram indicates the number of paving stones needed to
connect each house. The bridge requires a paving slab. What is
the smallest number of paving stones needed?
Give groups 10 minutes or so to come up with answers. 23 slabs are needed. Ask groups to indicate their
solution on a projected map. There are several correct solutions. Two are shown as exemplars, but the key
task is to get groups to articulate their strategy for solving it. Allow time for students to articulate and
discuss alternatives. There are many possibilities but intuitively, students will probably come up with
selecting the shortest connection first as a starting point. Two possible approaches generally follow, both
known as ‘greedy’ algorithms – they always take the best option available. Each results in an optimal
solution, known as a Minimum Spanning Tree (MST).
Prim’s Algorithm
Prims algorithm selects the lowest connector from the two houses first connected. It is demonstrated in the
subsequent slides, which can be introduced as a series of questions, each click building up the MST. It is
worth becoming familiar with the slide notes which contain the narrative. Although known as Prims
algorithm it was developed initially by a Czech mathematician, Vojtěch Jarník in 1930. Only later was it also
discovered independently by computer scientists Robert Prim (1957) and Edsger Dijkstra (1959).
Kruskal’s Algorithm
Prim’s algorithm is not the only one for finding a Minimum Spanning Tree. Another, often discovered
intuitively by children was developed by American computer scientist Joseph Kruskal in 1956. Challenge
pupils to spot the difference between this approach and Prim’s. A simple walkthrough is provided. As with
Prim’s we select the shortest edge as a starting point, but Kruskals algorithm takes the shortest connection,
regardless of whether it joins the existing path.
Minimum Spanning Trees provide the shortest connection utilising existing points. Either algorithm will
result in an optimal solution. They are widely used in many real world scenarios, a good example might be
planning the network cabling in the school. Knowing they have discovered a ‘real’ algorithm can be very
motivating for pupils. Can they think of other situations where finding a MST would be useful?
CAS Tenderfoot
Similar Problems
Many problems share similarities with a MST. A Steiner Tree shortens distances by introducing new interim
points but an optimal solution is difficult to compute. A CS Unplugged outdoor activity, Ice Roads could make
an extension activity. An explanation by NumberPhile: www.youtube.com/watch?v=dAyDi1aa40E is worth
watching. Soap bubbles will naturally form a local Steiner Tree. It is simple to demonstrate with a little
preparation.
The Create Maths ‘Working For Efficiency’ resources use real world graph problems.
‘Cable Connections’ involves finding a MST. Problems often appear similar, but can
be subtly different. In Muddy City, the MST challenge finds the shortest tree that
connected all nodes. ‘Deliveries’ looks for the shortest cycle - famously known as
the Travelling Salesman Problem. It is famous because no known algorithm can
solve it in a reasonable amount of time, even for a small number of locations. It is a
common misconception that as computers get faster and faster, they will eventually
be able to solve any problem such as this by ‘brute force’. But even with 8 locations,
all connected, a fast computer might take around 5 minutes to check every possible
combination. Just increasing that to 10 requires 5 hours, and with 20 locations, it
takes nearly 200 million years!
If this seems ridiculous, read the New Zealand CS Field Guide:
www.csfieldguide.org.nz/en/chapters/complexity-tractability.html. It explains the concept
of intractability well and has a nice interactive to show how such problems quickly
becomes intractable. Nonetheless, having just discovered Prims algorithm, there is no
harm in children having a go. With small graphs it is possible to get ‘good’ solutions, even if
we can’t prove they are optimal. Again, the focus is on developing a greedy strategy. The
website www.math.uwaterloo.ca/tsp/games/index.html has two games for children to
explore. Well worth investigating.
Is a task such as planning a paper round (the 3rd Create Maths activity) like any of the previous problems?
Can we use a previous strategy to solve this? Sadly we can’t. In this case, we need a solution that visits every
edge once, rather than every node, and returns to the starting point. These tours are known as Eulerian
Circuits, named after the mathematician Leonhard Euler (1707 -1783) and his first statement of this classic
problem, the Bridges of Konigsberg. Edge traceable graphs make great ‘pencil puzzles’. Students try to trace
a route along all the lines without taking their pencil off the paper.
Like Hamiltonian Cycles, finding an Eulierian Circuit is a very difficult problem for a computer. But being able
to say whether a graph contains an edge traceable circuit is much easier. It involves an investigation of the
properties of the graph. Encourage children to study the number of connections at each node. Can they spot
the pattern? The Create Maths teacher notes provide further pointers for structuring this investigation.
Investigations of this sort are ideal for developing the ability to generalise: observing specific examples,
spotting similarities and developing a general hypothesis that can be applied to all similar problems.
These algorithms fall under the heading of Discrete (or Decision)
Maths and many lie at the heart of Computer Science. The Nrich
Maths project (http://nrich.maths.org ) also has many activities that
can introduce Computational Thinking in KS3. The entire repository is
searchable by Topic. A good starting point is to select Topics –
Decision Mathematics – Network / Graph Theory. The results can
then be filtered by Key Stage. Each resource has hints to get children
going, solutions and teachers resources. The teacher notes, in
particular, are very useful, providing links to extensions and clear
explanations as to the purpose of the exercise.
2
Muddy City
Find the smallest number of
stone slabs so you can travel to
every building in muddy city?
The mathematics here is often used at work.
It solves a variety of networking problems.
paper rounds
von
ury
She also collects her at the end of her delivery.
esb
Av
e
ry
esb
u
af t
ur
esb
aft
Sh
Av
e
Av
e
rk
Vil
las
esb
ury
Sh
aft
Ba
ck
Sh
aft
esb
ury
Av
e
sce
nt
Pa
N Park Grove
Av
e
Cre
ury
hire
nt
esb
Pa
rk
Vil
las
aft
Sh
Working for efficiency
Cre
sce
Suth
erla
n
res
c
ury
aft
nt
ury
esb
nd
ons
Sh
sce
aft
erla
Dev
ck
Ba
Cre
Rd
Sh
Suth
dC
esb
her
Sut
hire
Sh
ck
Ba
dA
ve
nt
Devo
lan
Sha
ftes
bury
Suth
erla
n
d Cre
sce
dA
ve
Av
e
erlan
aft
esb
ury
Suth
Av
e
dA
ve
lan
Devo
ons
dA
ve
nt A
ve
Bea
Shaft
esbu
ry Rd
d
ent
Dev
Ba
ck
De
von
shir
eL
an
e
Lane
umo
s hire Cl
ose
yR
Sh
her
nshir
e Av
e
shire
Suth
erla
n
bur
lan
Sut
N Park Grove
Devon
shi
ftes
her
nt
Devon
Sh
dA
ve
Sha
Sut
d Cr
esce
v on
aft
Ba
ck
esb
ur
Sh
ury R
d
erlan
e
De
Suth
The round is some way from Pat's home so the
newsagent drops Pat off in her van.
an
aft
tesb
re
L
Av
e
dA
ve
Sut
Shaf
her
Bea
lan
umo
s hire Cl
ose
The roads marked show Pat's paper round.
De
shi
nt A
ve
Devo
De
v on
ck
nshir
e Lan
e
nshir
e Ave
nshi
Ba
Devo
Pat can save time if she can find a route where
she only walks along each road once.
Where should Pat be dropped off by the
newsagent and where should she be picked
up at the end of her round?
Getting there
Can you find the best route to deliver to every street?
Paper rounds
Which ones?
Find a rule which
predicts which
networks are
traceable.
Test your rule
with some
networks of
your own.
Working for efficiency
Getting there
Five of these
networks can be
traced without
taking your pencil
off the page.
Paper rounds worksheet
cable connections
The mathematics here is often used at work.
It solves a variety of networking problems.
Your task is to plan how to lay
cables for a cable TV service
between all the places on the map.
5
Westgate
1
Frenchy
Place
2
Grimsby
Bargate
Weelsby
Road
3
4
5
2
Waltham
3
Cleethorpes
6
2
1
Laying cable is very expensive so
you need to keep the total length
of cable as short as possible.
1
7
Golf Club
New
Waltham
Station Road
4
Humberston
5
Distances in kilometres
Working for efficiency
Make sure all the locations are connected.
They do not have to be connected directly, as the
signals travel along the cables at the speed of light!
You discover that due to planned engineering
works it will not be possible to lay cable directly
between Weelsby Road and New Waltham.
Getting there
Can you link these places using the shortest length of cable?
What is the shortest length of cable required now?
Cable connections
Find the minimum length of cable required to connect all the
locations in each of these networks:
2
4
7
8
6
3
3
4
7
8
4
4
6
13
9
3
2
12
4
9
6
5
8
8
10
4
10
11
4
4
3
3
5
4
2
1
6
3
2
1
2 3
5
4
4
4
4
4
2
3
Working for efficiency
1
3
3
3
5
3
5
2
5
5
4
2
3
3
4
5
5
2
3
3
3
2
4
6
2
3
7
3
4
4
3
3
4
2
3
3
2
4
2
Getting there
1
3
Cable connections worksheet
deliveries
The mathematics here is often used at work.
It solves a variety of networking problems.
You have to make deliveries to all the places marked in the map,
starting from your company's warehouse in Sheffield.
5
Ecclesfield
Kimberworth
4
7
6
3
Rotherham
Tinsley
Longley
Park
3
5
4
Hillsborough
4
3
Sheffield
5
9
The numbers beside the roads tell you
the distances between the places.
Catcliffe
Your task is to find the shortest route
to all the drop-off points, ending up
back at the warehouse in Sheffield.
Getting there
Can you find the best route to deliver to every town?
Distances in kilometres
Working for efficiency
Deliveries
In each case, find the shortest route which visits every place.
D
4
6
3
E
8
A
10
D
3
5
E
G
3
4
F
5
Total
distance =
10
13
5
11
12
F
5
B
C
Working for efficiency
Total
distance =
3
B
4
3
A
C
Start and
end at A
7
1D
2
E
4
6
5
J
7
H
12
7
2
Total
distance =
10
D
F
7
H
6
8
E
3
C
4
J
4
Start and end at A
A
2
4
6
C
B
8
4
4
4
3
Start at A and end at J
A
B
3
2
Start at A and end at F
F
4
3
17
G
Total
distance =
Getting there
1
Deliveries worksheet
Teacher notes
Getting there : Working for efficiency
nshi
The worksheet offers opportunities for further
exploration and then asks the pupils to search for a
rule and to prove their results. At some point it is
worth asking: can you have just one odd node?
Using tracing paper supports experimenting.
For lower attaining pupils, slipping the worksheet
into a plastic wallet will allow experimentation
using felt tip pens, wiping
off incorrect attempts, which may be easier.
Encourage pupils to look for what the edgetraceable networks have in common. Which graphs
can be traced whatever starting point is chosen?
Which graphs can be traced only if you start, and
end, at particular points? Pupils will test out their
theories better if they work together.
ck
shir
eL
an
Av
e
ry
sbu
fte
ur
esb
ck
S
aft
Sh
Ave
Sha
ftes
lan
d
bur
yR
erlan
Sh
res
cen
t
Av
e
ury
resc
ent
Pa
nsh
ire
C
rk
Dev
o
Vil
las
esb
aft
Sh
Ba
ck
Sut
her
Sh
aft
esb
u
ry
Av
e
lan
dA
ve
Devo
nshir
e Av
e
Sut
her
lan
dC
aft
esb
ent
ury
Sut
d Cre
sc
d
Av
e
her
Suth
e
ha
ry Rd
Ba
esbu
Sut
Bea
Shaft
von
Ave
umo
s hire Cl
ose
De
nshir
e Lan
e
nt A
ve
Devo
v on
N Park Grove
Edge-traceable graphs are explored in
Paper rounds. The starter activity offers a simple
version of a practical context in which to explore
the concept. The famous mathematician Euler
noticed that, to be edge-traceable, a network must
have at most two odd nodes.
De
This topic looks at simplified versions of
three different network problems that are
encountered in practical logistical planning.
Activity 1: Paper rounds
Activity 2: Cable connections
Activity 3: Deliveries
Ba
Devo
her
lan
d
Description
Cable connections provides a practical
example of a minimum connector problem.
It is quite possible to find a good or even an
optimal solution using trial and improvement
methods but the task provides the
opportunity to introduce pupils to the key
mathematical idea of an algorithm. Prim's
algorithm, to find this minimum spanning
tree, is quite within the grasp of many pupils,
even at key stage 3.
For some of the problems on the worksheet,
there is more than one optimum solution.
Prim's algorithm works as follows:
Step 1: Choose an arbitrary location, say
Grimsby, and connect it to the nearest place,
in this case, Westgate. Note the distance.
Step 2: Find the nearest place not yet in the
solution, in this case either Frenchy place or
Wheelsby Road. Whenever you get a choice
of connections of equal length, choose
either one. Here we have arbitrarily chosen
Frenchy place.
Continue this process until all the locations
are connected.
Working for efficiency
Page 1
Teacher notes
Getting there : Working for efficiency
Deliveries illustrates a very familiar problem in
logistics. Finding the shortest route to a set of
delivery points will save on both time and money.
For a relatively small network like the problem
offered here, the shortest route may be found by
trial and improvement methods, or by
considering all the possible routes. Pupils will
develop helpful strategies, for example, they
might decide to try to avoid longer stages, like
the road which goes directly from Sheffield to
Catcliffe.
You can extend this activity for pupils who solve
the initial problem by making one or two of the
roads one-way, or by making one of the roads
impassable. Both of these variations do, of
course, represent real features of shortest route
problems as applied to road systems.
In this type of problem, the number of
calculations needed to exhaust every possibility
increases very fast. Because of the very large
number of computations required to be sure of
the best solution, mathematicians have
developed algorithms which give good solutions
for problems that are too large to test for every
possible solution. Pupils may be intrigued to find
out that, to date, there is no known algorithm
which can guarantee a best solution for a large
number of locations – an unsolved problem in
mathematics. If they have derived some helpful
strategies, can they find networks where their
approach fails to provide the optimal solution?
The mathematics
Paper rounds offers the opportunity for
reasoning and proof as the arguments needed
to establish Euler's theorem are within their
grasp. It also, along with Cable connections
and Deliveries, offers opportunities for the
mathematical skills of planning, being
systematic, recording and logical experiment.
The algorithmic thinking developed is
picked up in key stage 5 in the decision
maths curriculum.
Working for efficiency
Page 2