Skip to content

D1 · Decision Mathematics 1

Edexcel International A-Level MathematicsTopic 9

Video lesson for this topic Open the video page
15:59

Decision Mathematics 1

Why it matters. One morning in 1956, Edsger Dijkstra, a 26-year-old programmer at the Mathematical Centre in Amsterdam, was shopping with his fiancée. Tired…

English narration · English and 中文 subtitles you can switch

1.1.1

Decision Mathematics 1: algorithms, networks and linear programming

Why it matters. One morning in 1956, Edsger Dijkstra, a 26-year-old programmer at the Mathematical Centre in Amsterdam, was shopping with his fiancée. Tired, they sat down at a café, and in about twenty minutes, without pen or paper, he worked out a way to find the shortest route between two places on a map. He wanted a problem that anyone could understand to show off a new computer, the ARMAC, so he used a simplified road map of 64 Dutch towns. He published the method in 1959. Today a version of Dijkstra's algorithm runs every time a phone plans a journey or the internet routes a message. Decision mathematics is the study of methods like this: exact step-by-step procedures, called algorithms, that solve practical problems.

In this unit you will:

  • carry out sorting and bin packing algorithms;
  • find minimum spanning trees and shortest paths in networks;
  • solve route inspection and travelling salesman problems;
  • analyse projects with critical path networks;
  • formulate and solve linear programming problems.

Edexcel International Advanced Subsidiary, Decision Mathematics 1 (D1, paper WDM01/01, 1 hour 30 minutes, 75 marks). Pure Mathematics 1 is assumed. Most marks are for carrying out an algorithm exactly and showing the working in the required form.

Four families of D1 algorithms, sorting and bin packing, spanning trees and shortest paths, route inspection and travelling salesman, critical paths and linear programming, each with the form its answer must take
Every D1 method is an algorithm: the marks are for exact steps in the required form
Task What you must show
sorting the list after each pass, and each pivot in a quick sort
bin packing which item goes in which bin
Kruskal, Prim the edges in the order you choose them, and the total weight
Dijkstra the order of permanent labels, the final labels and the route
route inspection the odd vertices, every pairing with its total, and the final length
linear programming the variables, the objective and every constraint, including $x, y \ge 0$
1.1.1 1.1.2

Sorting and packing algorithms

An algorithm is a finite list of exact instructions.

Bubble sort 冒泡排序 (into ascending order): go through the list comparing each pair of neighbouring items, and swap them if they are in the wrong order. After each pass, the largest remaining item has reached its place at the end. Stop after a pass with no swaps.

Worked example 1. Sort 5, 1, 4, 2, 8 into ascending order with a bubble sort.

  • Pass 1: swap 5 and 1, swap 5 and 4, swap 5 and 2, leave 5 and 8: the list is 1, 4, 2, 5, 8.
  • Pass 2: leave 1 and 4, swap 4 and 2, leave 4 and 5: the list is 1, 2, 4, 5, 8.
  • Pass 3: no swaps, so the list is sorted.

Quick sort 快速排序: choose the middle item of the list as the pivot (for $n$ items, the item in position $\frac{n+1}{2}$, rounding up if needed). Write the items smaller than the pivot before it, and the items larger after it, keeping their order. Then repeat with each sublist until every item has been a pivot or is in a sublist of one item.

Worked example 2. Sort 9, 2, 7, 5, 3, 4, 6 with a quick sort.

  • The middle item (4th of 7) is 5: 2, 3, 4, 5, 9, 7, 6.
  • Sublist 2, 3, 4 has pivot 3, and is already in order. Sublist 9, 7, 6 has pivot 7: 6, 7, 9.
  • The sorted list is 2, 3, 4, 5, 6, 7, 9.
Quick sort of 9, 2, 7, 5, 3, 4, 6 in four rows: pivot 5 boxed; after the first pass 2, 3, 4, 5, 9, 7, 6 with the two sublists bracketed; sublist pivots 3 and 7 boxed; final row 2, 3, 4, 5, 6, 7, 9
Quick sort with the middle-item pivot: quote the pivot and the list after every partition

Bin packing 装箱问题 puts items into the fewest bins of a fixed size. A lower bound for the number of bins is the total size divided by the bin size, rounded up.

  • First-fit: take the items in the order given, and put each in the first bin with room.
  • First-fit decreasing: sort the items into descending order first, then use first-fit.
  • Full-bin: look for combinations that fill a bin exactly, then use first-fit for the rest.

Worked example 3. Pack items of sizes 7, 5, 4, 3, 6, 2 into bins of size 10.

  • Lower bound: $\frac{27}{10} = 2.7$, so at least 3 bins.
  • First-fit: 7 → bin 1; 5 → bin 2 (no room in bin 1); 4 → bin 2; 3 → bin 1; 6 → bin 3; 2 → bin 3. Bins: (7, 3), (5, 4), (6, 2).
  • First-fit decreasing, with 7, 6, 5, 4, 3, 2: bins (7, 3), (6, 4), (5, 2).
  • Both use 3 bins, which equals the lower bound, so they are optimal.
Vocabulary Train
English
bubble sort/ˈbʌbl sɔːt/
quick sort/kwɪk sɔːt/
bin packing/bɪn ˈpækɪŋ/
1.2.1 1.2.2

Minimum spanning trees

A network is a graph whose edges have weights, such as distances or costs. A spanning tree connects all the vertices with no cycles. A minimum spanning tree 最小生成树 (MST) is a spanning tree with the least total weight.

  • Kruskal's algorithm 克鲁斯卡尔算法: list the edges in order of weight. Add the smallest edge that does not make a cycle, and repeat until every vertex is connected.
  • Prim's algorithm 普里姆算法: start at any vertex. Repeatedly add the smallest edge that joins a vertex in the tree to a vertex not yet in the tree.

Prim's algorithm also works on a distance matrix: cross out the row of each vertex you add, and look for the smallest number in the columns of the vertices already in the tree.

Left: the network of worked examples 4 and 5, with the MST AC, CD, CB and the Dijkstra labels A 0, C 2, D 3, B 4. Right: the feasible region of worked example 9, with the objective line touching the optimum at (4, 6).
Left: the network of worked examples 4 and 5, with the MST AC, CD, CB and the Dijkstra labels A 0, C 2, D 3, B 4. Right: the feasible region of worked example 9, with the objective line touching the optimum at (4, 6).

Worked example 4. A network has edges AB 4, AC 2, BC 3, BD 5 and CD 1.

  • Kruskal: CD 1, AC 2, BC 3; then AB 4 and BD 5 are rejected because they would make cycles.
  • Prim from A: AC 2, then CD 1, then CB 3.
  • Both give the MST AC, CD, CB, with total weight 6.
Vocabulary Train
English
minimum spanning tree/ˈmɪnɪməm ˈspænɪŋ triː/
Kruskal's algorithm/ˈkrʌsklz ˈælɡərɪθəm/
Prim's algorithm/prɪmz ˈælɡərɪθəm/
1.2.2

Shortest paths

Dijkstra's algorithm 迪杰斯特拉算法 finds the shortest path from a start vertex to every other vertex, when the weights are not negative.

  1. Give the start vertex the permanent label 0.
  2. For each vertex joined to the vertex just made permanent, work out the permanent label + the edge weight. If this is smaller than its current temporary label, replace the label.
  3. Make the smallest temporary label permanent, and go back to step 2 until the destination is permanent.

To find the route, work backwards from the destination: a vertex is on the route if the difference between the labels equals the weight of the edge.

A metro map is a network: stations are vertices and the lines between them are edges
A metro map is a network: Dijkstra's algorithm finds the shortest route between two stations

Worked example 5. Use Dijkstra's algorithm on the network in worked example 4 to find the shortest distances from A.

  • A = 0, permanent. Temporary labels: B 4, C 2.
  • C = 2, permanent. From C: B would be $2 + 3 = 5$, larger than 4, so B stays 4; D becomes $2 + 1 = 3$.
  • D = 3, permanent. From D: B would be $3 + 5 = 8$, so B stays 4.
  • B = 4, permanent.
  • The shortest route from A to D is A–C–D, of length 3; from A to B it is the direct edge, of length 4.
Vocabulary Train
English
Dijkstra's algorithm/ˈdeɪkstrəz ˈælɡərɪθəm/
1.3.1

The Chinese postman problem

The route inspection (Chinese postman) problem 中国邮递员问题 asks for the shortest closed route that travels along every edge at least once, for example a road gritter or a postman.

  • If every vertex has even degree, the shortest route is the total weight of the edges.
  • Otherwise, list the odd vertices. Find every way to pair them up, and the shortest distance for each pair. Choose the pairing with the smallest total, and repeat those edges.
  • Shortest route = total weight of all edges + the smallest pairing total.

Worked example 6. For the network in worked example 4, the edges total 15. The degrees are A 2, B 3, C 3 and D 2, so B and C are the odd vertices. The shortest path from B to C is BC, of weight 3. So the shortest route has length $15 + 3 = 18$, with BC travelled twice.

Vocabulary Train
English
route inspection (Chinese postman) problem/ruːt ɪnˈspekʃn ˈprɒbləm/
1.3.2 1.3.3 1.3.4

The travelling salesman problem

In the classical travelling salesman problem 旅行商问题, a route must visit every vertex exactly once and return to the start. Checking every route takes far too long for large networks, so we find bounds instead.

  • Upper bound: an actual route. Doubling the weight of the MST gives one; shortcuts improve it. The nearest neighbour algorithm 最近邻算法 also gives one: from the start, go to the nearest unvisited vertex each time, then return to the start.
  • Lower bound: delete one vertex, find the MST of the rest, and add the two smallest edges from the deleted vertex.

The best route lies between the best lower bound and the best upper bound. If the network is not complete, first make a table of shortest distances between every pair of vertices.

Worked example 7. A complete network has edges AB 4, AC 2, AD 7, BC 3, BD 5, CD 6.

  • Nearest neighbour from A: A–C (2), C–B (3), B–D (5), D–A (7). Total 17, an upper bound.
  • The MST is AC, BC, BD, with total 10, so doubling gives the weaker upper bound 20.
  • Lower bound, deleting A: the MST of B, C, D is BC + BD = 8, and the two smallest edges from A are AC + AB = 6. So the lower bound is 14.
  • So $14 \le$ optimal route $\le 17$. With only four vertices, we can check all three routes: A–B–C–D–A = 20, A–B–D–C–A = 17 and A–C–B–D–A = 17. The optimal route has length 17.
The complete network on A, B, C, D with weights AB 4, AC 2, AD 7, BC 3, BD 5, CD 6; the nearest-neighbour tour A–C–B–D–A is drawn in orange with steps numbered 1 to 4, beside the working: tour 17 is an upper bound, deleting A gives the lower bound 14
Nearest neighbour gives an upper bound, the deleted-vertex MST a lower bound: the optimal tour lies between 14 and 17
Vocabulary Train
English
classical travelling salesman problem/ˈklæsɪkl ˈtrævəlɪŋ ˈseɪlzmən ˈprɒbləm/
nearest neighbour algorithm/ˈnɪərɪst ˈneɪbə ˈælɡərɪθəm/
1.4.1 1.4.2 1.4.3 1.4.4

Critical path analysis

A project is made of activities, some of which must wait for others to finish. A precedence table lists them. In an activity-on-arc network 活动在弧上的网络, each activity is an arc and each event (the start or end of activities) is a node. A dummy 虚活动 is an arc of zero duration, shown dashed, used when two activities would otherwise have the same start and end events, or to show a dependence correctly.

  • Earliest event times 最早事件时间: work forwards from 0. At each event, take the largest of (earliest time of the previous event + duration).
  • Latest event times 最晚事件时间: work backwards from the end. At each event, take the smallest of (latest time of the next event − duration).
  • Total float 总时差 of an activity $=$ latest finish time $-$ earliest start time $-$ duration.
  • A critical path 关键路径 is a path of activities with zero total float. Its length is the shortest time in which the project can be completed.

A Gantt chart 甘特图 (cascade chart) shows each activity as a bar starting at its earliest start time, with its float shown after it. It is used to schedule workers.

Worked example 8. Activities: A (3 days), B (4 days), C (4 days, after A), D (1 day, after B) and E (5 days, after C and D).

  • Earliest times: A ends at 3, B at 4, C at 7, D at 5. E starts at $\max(7, 5) = 7$ and ends at 12.
  • The critical path is A–C–E, and the project takes 12 days.
  • D must finish by 7, so its total float is $7 - 4 - 1 = 2$ days. B must finish by 6, so its float is $6 - 0 - 4 = 2$ days.
Left: the first-fit bins of worked example 3. Right: the activity network of worked example 8, with the critical path A–C–E highlighted.
Left: the first-fit bins of worked example 3. Right: the activity network of worked example 8, with the critical path A–C–E highlighted.
Vocabulary Train
English
activity-on-arc network/ækˈtɪvɪti ɒn ɑːk ˈnetwɜːk/
dummy/ˈdʌmi/
earliest event times/ˈɜːlɪɪst ɪˈvent taɪmz/
latest event times/ˈleɪtɪst ɪˈvent taɪmz/
total float/ˈtəʊtl fləʊt/
critical path/ˈkrɪtɪkl pæθ/
Gantt chart/ɡænt tʃɑːt/
1.5.1 1.5.2 1.5.3

Linear programming

To formulate a linear programming problem:

  1. define the decision variables, for example "$x$ is the number of chairs made each day";
  2. write the objective: maximise or minimise an expression such as $P = 3x + 2y$;
  3. write every constraint as an inequality, including $x \ge 0$ and $y \ge 0$.

To solve with two variables, draw each constraint and shade the region that is not wanted, leaving the feasible region. Then find the optimal point:

  • the ruler method 尺子法: draw a line of the objective and slide a ruler parallel to it; the last point of the feasible region it touches is optimal;
  • the vertex method 顶点法: work out the objective at each vertex of the feasible region and choose the best.

If the variables must be whole numbers, test the integer points near the optimal vertex that lie inside the feasible region.

Worked example 9. Maximise $P = 3x + 2y$ subject to $x + y \le 10$, $2x + y \le 14$, $x \ge 0$, $y \ge 0$.

  • The lines $x + y = 10$ and $2x + y = 14$ meet where $x = 4$, $y = 6$.
  • The vertices of the feasible region are $(0, 0)$, $(7, 0)$, $(4, 6)$ and $(0, 10)$, giving $P = 0$, 21, 24 and 20.
  • The maximum is $P = 24$, at $x = 4$, $y = 6$.
Vocabulary Train
English
ruler method/ˈruːlə ˈmeθəd/
vertex method/ˈvɜːteks ˈmeθəd/
1.5.1 1.5.2 1.5.3

Sources for this lesson

  • Pearson Edexcel, International Advanced Level Mathematics, Further Mathematics and Pure Mathematics specification (2018), unit D1.
  • E. W. Dijkstra, "A note on two problems in connexion with graphs", Numerische Mathematik, 1 (1959).
  • Worked examples written for this lesson in the style of WDM01 questions.
1.5.1 1.5.2 1.5.3

Common errors

  • Not showing the list after each pass of a sort.
  • In a quick sort, choosing the first item as the pivot instead of the middle one.
  • In Kruskal's algorithm, adding an edge that makes a cycle.
  • In Dijkstra's algorithm, not recording the order in which labels become permanent.
  • In route inspection, giving only one pairing of the odd vertices instead of all of them.
  • Calling the nearest neighbour route the optimal route; it is only an upper bound.
  • Forgetting a dummy, or forgetting the non-negativity constraints.
  • Shading the feasible region instead of the unwanted region, when the question says to shade what is not wanted.
1.5.1 1.5.2 1.5.3

Key terms

  • Minimum spanning tree: a tree connecting all the vertices with the least total weight.
  • Dijkstra's algorithm: an algorithm for the shortest path from one vertex to the others.
  • Route inspection problem: finding the shortest closed route that uses every edge.
  • Critical path: the longest path through an activity network; its activities have zero float.
  • Total float: the time by which an activity can be delayed without delaying the project.
  • Feasible region: the set of points that satisfy all the constraints.
1.5.1 1.5.2 1.5.3

Check yourself

  1. How many passes does a bubble sort of 4, 3, 2, 1 need, including the final pass with no swaps?
  2. Items of sizes 6, 6, 5, 4, 3 go into bins of size 10. Find the lower bound for the number of bins.
  3. A network has 8 vertices. How many edges does a spanning tree have?
  4. A network has four odd vertices. How many ways are there to pair them?
  5. An activity has earliest start 5, latest finish 14 and duration 6. Find its total float.
  6. Find the maximum of $P = x + 3y$ at the vertices $(0, 0)$, $(6, 0)$, $(4, 3)$ and $(0, 4)$.

Answers: 1. 4 (3 passes with swaps, then one with none). 2. $\frac{24}{10} = 2.4$, so 3. 3. 7. 4. 3. 5. $14 - 5 - 6 = 3$. 6. 13, at $(4, 3)$.

Interactive lessons on this topic

Work through it step by step, with instant-check exercises.

More topics in Edexcel International A-Level Mathematics

Log in or create account

IGCSE, A-Level & AP