KS Maths
Topic 3.16 · Applications and Interpretation HL

Tree and cycle algorithms

Nearest neighbour is a bound, not an answer

Take the cheapest road at every step and you get 23. Every choice was the best available, and the tour is still not the best tour: the true shortest is 22.

Words you need (10 key words in this lesson)

The maths words this lesson uses, in plain English. Open this before you start if English is not your first language.

vertex
A corner of a shape. Also, the turning point of a parabola.A triangle has three vertices.
edge
A line where two faces meet. In graph theory, a line joining two points.A cube has twelve edges.
odd
A whole number that leaves remainder 1 when divided by 2.7 is an odd number.
degree
The highest power of x in a polynomial. Also, the unit for measuring angles.The degree of x cubed plus x is 3.
exact
Not rounded. Completely correct.The exact answer is one third, not 0.33.
twice
Two times as much.Twice 4 is 8.
less than
Not as big as. The sign is <.3 is less than 5.
greater than
Bigger than. The sign is >.5 is greater than 3.
at most
This number or less.At most 5 means 5 or less.
distance
How far it is from one place to another.The distance is 5 kilometres.

Preview You are reading the start of this lesson. The rest opens with a plan. See plans Already paid? Sign in

Warm-up

Four quick ones from earlier work. Try each on paper before you open the answer.

  1. The degrees of five vertices are A 3, B 4, C 3, D 2 and E 2. Which vertices are odd?
    Answer

    A and C: two odd vertices. Every degree sum is even, so there is always an even number of odd vertices. Two odd vertices are exactly the case where an Eulerian trail exists but a circuit does not.

  2. How many edges does a spanning tree on 8 vertices have?
    Answer

    7. A tree on n vertices has n − 1 edges: one fewer edge than vertices, because a tree has no cycle.

  3. Roads join towns A to B (5 km), B to C (3 km) and A to C (10 km). What is the least distance from A to C?
    Answer

    8 km, going through B. The direct road is longer, so a table of least distances replaces 10 with 8.

  4. The route A–B–C–D–B–E uses no road twice but visits B twice. Is it a path, a trail or neither?
    Answer

    A trail. A path may not repeat a vertex, and B is repeated; a trail may repeat vertices but not edges. The five route words differ in exactly what they may repeat.

Words used in this lesson
weight
the number on an edge: a distance, a cost or a time. For example: a road of 7 km has weight 7.
spanning tree
edges that join every vertex and contain no cycle. For example: 4 edges for 5 towns.
minimum spanning tree
the spanning tree with the smallest total weight. For example: the cheapest way to connect every town.
upper bound
a number the answer cannot be bigger than. For example: a tour of length 23 means the best is at most 23.
lower bound
a number the answer cannot be smaller than. For example: if no tour can be shorter than 20, 20 is a lower bound.
nearest neighbour
go to the closest town you have not visited yet, each time. For example: the greedy method for an upper bound.
odd vertex
a vertex with an odd number of edges. For example: a vertex with 3 roads is odd.
circuit / cycle
a route that comes back to where it started. For example: a cycle repeats no vertex; a circuit may.
algorithm
a fixed list of steps that gives the answer. For example: Kruskal is an algorithm.
state / explain
say what you have shown, and give the reason. For example: “state what kind of bound this is”.
4976583275ABCDETen roads with their lengths. A tour must visit every town once and come home.An upper bound is a tour that exists. A lower bound is a number no tour can go under.
no route yetthis route's total
22the true shortest
pick a routeverdict

Two tours of the same five towns, one built greedily and one optimal. They are not the same tour.

The five words, in order of strictness

WordWhat it may repeatClosed?
WalkAnything: edges and verticesEither
TrailVertices, but no edge twiceEither
PathNothingOpen
CircuitVertices, but no edge twiceClosed
CycleNothing except the start, which is also the endClosed
Named routeVisitsExists when
Eulerian trailevery EDGE oncethe graph is connected AND exactly 0 or 2 vertices have odd degree
Eulerian circuitevery EDGE once, and returnsthe graph is connected AND every vertex has even degree
Hamiltonian pathevery VERTEX onceno simple test exists
Hamiltonian cycleevery VERTEX once, and returnsno simple test exists

Euler is about edges and Hamilton is about vertices. The two words are the thing questions swap on you. Connectivity sits in both Euler rows for a reason: two disjoint triangles have every degree even and no Eulerian circuit at all. And note the asymmetry: Euler has a five-second test and Hamilton has no simple test at all, which is why the travelling salesman problem is met with bounds rather than an exact method.

The rest of this lesson is in the full course

Still to come in this lesson:

In the full lesson every figure moves as you drag it, and every answer you type is checked, with a note on what each wrong answer means.

IB Diploma plan: AI HL$99Every Diploma lesson in both courses and both levels, so a change of course never locks you out, and every lesson from Year 7 for the refreshers. $99 for 12 months or $149 for 2 years.

One plan opens every Diploma lesson, AA and AI, SL and HL, for the whole family.

One payment. Nothing renews. Full refund within 30 days. Prices are in US$; Gumroad shows your local currency at checkout. Pay by card on Gumroad, then come back here and type the email you paid with: we email you a sign-in link. For a refund, reply to your Gumroad receipt or email hello@ksmaths.com.

Try a free sample lesson in every unit, and the whole Skill Tree. See this unit.

Already have a revision pack or the Years 7 to 11 plan? Move up and the unused part of what you paid comes off.

Teaching students who need extra support? Student codes for 5, 10 or 30 students.

AI HL Mock Exam Pack, $25BuyPlan $99