D1-2 Algorithms on graphs — revision question pack

2 specification points · notes, questions, answers and worked methods

Checked against Edexcel 9FM0 section D1-2. Review basis: the qualification registry sourced from the Pearson Edexcel Level 3 Advanced GCE in Further Mathematics (9FM0) specification; registry verification recorded 17 July 2026.

How this checking works

D1-2.1 · The minimum spanning tree (minimum connector) problem. Prim's and Kruskal's algorithm.

Explanation

  • A spanning tree of a connected network on nn vertices uses every vertex and exactly n1n-1 arcs and contains no cycle; the minimum spanning tree, or minimum connector, is the one of least total weight.
  • Kruskal's algorithm sorts every arc into ascending order of weight and then adds arcs one at a time, rejecting any arc that would form a cycle, stopping once n1n-1 arcs are in the tree.
  • Prim's algorithm grows a single tree from a chosen start vertex: at each stage it adds the shortest arc joining a vertex already in the tree to a vertex not yet in it, and it never needs a cycle check because one endpoint is always outside the tree.
  • Prim's algorithm also runs directly on a distance matrix: delete the row of the newly connected vertex, label its column, and scan every labelled column for the smallest uncrossed entry.
  • Both algorithms return a tree of the same minimum weight, though the arcs may be listed in a different order and different trees of equal weight can occur when weights are repeated.

Worked example

A network has vertices AA, BB, CC, DD and arcs AB=8AB=8, AC=3AC=3, AD=9AD=9, BC=5BC=5, BD=7BD=7, CD=6CD=6. Use Kruskal's algorithm to find the minimum spanning tree.

  1. 1.In ascending order the arcs are AC=3AC=3, BC=5BC=5, CD=6CD=6, BD=7BD=7, AB=8AB=8, AD=9AD=9.
  2. 2.Accept ACAC; accept BCBC; accept CDCD.
  3. 3.The tree now has 3=413=4-1 arcs, so the algorithm stops; BDBD, ABAB and ADAD would all create cycles.
  4. 4.The total weight is 3+5+6=143+5+6=14.

Answer: The minimum spanning tree uses ACAC, BCBC and CDCD and has weight 1414.

Common mistakes

  • Don't fall into the trap of continuing past n1n-1 arcs, or stopping before every vertex is connected.
  • Don't fall into the trap of sorting the arcs for Prim's algorithm, which is a Kruskal step and wastes time.
  • Don't fall into the trap of deleting a column instead of a row in the matrix form of Prim's algorithm, or forgetting to scan every labelled column.

Exam tip

State the arcs in the order your algorithm selects them; examiners award marks for the correct selection order as well as the final weight.

Tier 1 · Easy

  1. 1.

    A network has vertices AA, BB, CC, DD, EE and arcs AB=6AB=6, AC=4AC=4, BC=3BC=3, BD=9BD=9, CD=5CD=5, CE=8CE=8, DE=7DE=7. Use Kruskal's algorithm to find a minimum spanning tree, listing the arcs in the order you consider them, and state its total weight.

    (5)

    (Total for Question 1 is 5 marks)

  2. 2.

    Explain what is meant by a spanning tree, and state how many arcs a spanning tree of a connected network with 99 vertices must contain.

    (3)

    (Total for Question 2 is 3 marks)

Tier 2 · Standard

  1. 1.

    A network has vertices AA to FF and arcs AB=9AB=9, AC=5AC=5, AD=12AD=12, BC=7BC=7, BE=8BE=8, CD=6CD=6, CE=11CE=11, CF=13CF=13, DF=10DF=10, EF=4EF=4. Use Prim's algorithm starting at AA to find a minimum spanning tree, stating the arcs in the order they are added and the total weight.

    (6)

    (Total for Question 1 is 6 marks)

  2. 2.

    For the network with vertices AA to FF and arcs AB=9AB=9, AC=5AC=5, AD=12AD=12, BC=7BC=7, BE=8BE=8, CD=6CD=6, CE=11CE=11, CF=13CF=13, DF=10DF=10, EF=4EF=4, apply Kruskal's algorithm. List the arcs in the order you consider them, name any arc you reject together with the reason, and state the total weight.

    (6)

    (Total for Question 2 is 6 marks)

  3. 3.

    A network has vertices AA to GG and arcs AB=14AB=14, AC=10AC=10, AD=17AD=17, BC=8BC=8, BE=13BE=13, CD=9CD=9, CE=16CE=16, CF=21CF=21, DF=12DF=12, EF=7EF=7, EG=19EG=19, FG=11FG=11. Apply Kruskal's algorithm and state the arcs of the minimum spanning tree and its weight.

    (6)

    (Total for Question 3 is 6 marks)

Tier 3 · Hard

  1. 1.

    Apply Prim's algorithm starting at AA to the network with vertices AA to GG and arcs AB=14AB=14, AC=10AC=10, AD=17AD=17, BC=8BC=8, BE=13BE=13, CD=9CD=9, CE=16CE=16, CF=21CF=21, DF=12DF=12, EF=7EF=7, EG=19EG=19, FG=11FG=11. State the order in which the vertices join the tree, the arcs used, and verify that the weight agrees with Kruskal's answer of 5757.

    (7)

    (Total for Question 1 is 7 marks)

  2. 2.

    Explain why Prim's algorithm never needs to test for a cycle, whereas Kruskal's algorithm does, and describe one practical situation in which Kruskal's algorithm is the more convenient of the two.

    (5)

    (Total for Question 2 is 5 marks)

  3. 3.

    A network on vertices AA to FF has arcs AB=9AB=9, AC=5AC=5, AD=12AD=12, BC=7BC=7, BE=8BE=8, CD=6CD=6, CE=11CE=11, CF=13CF=13, DF=10DF=10, EF=4EF=4. Apply Prim's algorithm starting at DD instead of AA, and explain why the resulting tree has the same weight as the tree obtained starting at AA.

    (7)

    (Total for Question 3 is 7 marks)

  4. 4.

    A minimum spanning tree of a network on 66 vertices has weight 3030. One arc of the tree, of weight 88, is removed from the network because that link is closed. The shortest arc that reconnects the two parts of the tree has weight 1313. State the weight of the new minimum spanning tree, and explain why the answer would be wrong if the replacement arc had joined two vertices in the same part.

    (6)

    (Total for Question 4 is 6 marks)

  5. 5.

    A network on vertices AA to EE has arcs AB=6AB=6, AC=4AC=4, BC=3BC=3, BD=9BD=9, CD=5CD=5, CE=8CE=8, DE=7DE=7. The arc CDCD is now given the new weight kk, where k>0k>0. Determine the values of kk for which the minimum spanning tree still uses CDCD, and state the weight of the minimum spanning tree when k=10k=10.

    (7)

    (Total for Question 5 is 7 marks)

D1-2.2 · Dijkstra's and Floyd's algorithm for finding the shortest path.

Explanation

  • Dijkstra's algorithm finds the shortest path from one start vertex to every other. Each vertex carries a box with three entries: the order of labelling, the final label, and a list of working values.
  • Give the start vertex final label 00, then repeatedly choose the smallest working value anywhere in the network, make it final,
  • and update every unlabelled neighbour with the sum of the new final label and the connecting arc, recording the new value only if it beats the values already there. To recover the route, trace back from the end vertex, keeping an arc XYXY whenever the final label of YY minus the final label of XX equals the weight of XYXY.
  • Floyd's algorithm instead finds the shortest distance between every pair. Start with the distance matrix and a route matrix whose column jj is filled with jj.
  • On iteration kk compare each entry dijd_{ij} with dik+dkjd_{ik}+d_{kj}; if the route through kk is shorter, replace dijd_{ij} and set the route entry rijr_{ij} to rikr_{ik}. Iteration kk works on the kkth row and column, and after nn iterations the matrices are complete.

Worked example

In a network with vertices AA, BB, CC, DD and arcs AB=4AB=4, AC=7AC=7, BC=2BC=2, BD=8BD=8, CD=3CD=3, use Dijkstra's algorithm from AA to find the shortest path to DD.

  1. 1.AA is labelled first with final label 00.
  2. 2.Working values become B=4B=4 and C=7C=7; the smaller is BB, labelled second with final label 44.
  3. 3.From BB, CC receives 4+2=64+2=6, which beats 77, and DD receives 4+8=124+8=12; CC is labelled third with final label 66.
  4. 4.From CC, DD receives 6+3=96+3=9, which beats 1212, so DD is labelled fourth with final label 99.

Answer: The shortest path is ABCDABCD with length 99, found by tracing back from DD through the arcs whose weights match the differences in final labels.

Common mistakes

  • Don't fall into the trap of overwriting a working value with a larger number instead of keeping the smallest so far.
  • Don't fall into the trap of updating a vertex that already has a final label.
  • Don't fall into the trap of changing a Floyd route entry to kk rather than to the current value of rikr_{ik}.

Exam tip

Never rub out a working value: examiners award marks for the full list of working values in each box, and the crossed-out values show the algorithm was followed.

Tier 1 · Easy

  1. 1.

    A network has vertices AA, BB, CC, DD, EE and arcs AB=4AB=4, AC=7AC=7, BC=2BC=2, BD=8BD=8, CD=3CD=3, CE=9CE=9, DE=5DE=5. Use Dijkstra's algorithm from AA to find the final label of every vertex and the shortest path from AA to EE.

    (6)

    (Total for Question 1 is 6 marks)

  2. 2.

    State what the three entries in a Dijkstra box represent, and explain why a vertex may hold more than one working value.

    (3)

    (Total for Question 2 is 3 marks)

Tier 2 · Standard

  1. 1.

    A network has vertices AA to FF and arcs AB=5AB=5, AC=8AC=8, BC=2BC=2, BD=9BD=9, CD=4CD=4, CE=7CE=7, DF=6DF=6, EF=4EF=4. Use Dijkstra's algorithm from AA to complete every box and find the shortest route from AA to FF.

    (7)

    (Total for Question 1 is 7 marks)

  2. 2.

    A network has vertices AA to GG and arcs AB=6AB=6, AC=9AC=9, AD=11AD=11, BC=4BC=4, BE=12BE=12, CD=5CD=5, CE=8CE=8, CF=14CF=14, DF=10DF=10, EF=3EF=3, EG=15EG=15, FG=7FG=7. Use Dijkstra's algorithm from AA to find the final labels of EE, FF and GG, listing the working values in each of those three boxes.

    (7)

    (Total for Question 2 is 7 marks)

  3. 3.

    A network has vertices AA, BB, CC, DD with AB=7AB=7, AD=4AD=4, BC=3BC=3, CD=2CD=2 and no direct arcs ACAC or BDBD. Write down the initial distance matrix and route matrix used by Floyd's algorithm, and carry out the first iteration.

    (6)

    (Total for Question 3 is 6 marks)

Tier 3 · Hard

  1. 1.

    For the network on AA, BB, CC, DD with AB=7AB=7, AD=4AD=4, BC=3BC=3, CD=2CD=2 and no direct arcs ACAC or BDBD, complete Floyd's algorithm and write down the final distance matrix and final route matrix. Use them to state the shortest route from AA to CC and from BB to DD.

    (8)

    (Total for Question 1 is 8 marks)

  2. 2.

    Explain why Dijkstra's algorithm can stop as soon as the destination vertex receives a final label, and explain why Floyd's algorithm must always complete all nn iterations.

    (6)

    (Total for Question 2 is 6 marks)

  3. 3.

    For the network on AA to GG with arcs AB=6AB=6, AC=9AC=9, AD=11AD=11, BC=4BC=4, BE=12BE=12, CD=5CD=5, CE=8CE=8, CF=14CF=14, DF=10DF=10, EF=3EF=3, EG=15EG=15, FG=7FG=7, state the shortest route from AA to GG and its length, and determine the greatest amount by which the arc EFEF could be lengthened before that route stops being shortest.

    (8)

    (Total for Question 3 is 8 marks)

  4. 4.

    In a Dijkstra run on a network with vertices AA to EE, vertex CC has final label 1212 and vertex EE has final label 1919, and the arc CECE has weight 77. State what this tells you about the shortest route to EE, and explain why the equality alone does not prove that CC lies on every shortest route to EE.

    (5)

    (Total for Question 4 is 5 marks)

  5. 5.

    In the network on AA to FF with arcs AB=5AB=5, AC=8AC=8, BC=2BC=2, BD=9BD=9, CD=4CD=4, CE=7CE=7, DF=6DF=6, EF=4EF=4, the vertex CC must be avoided because of roadworks. Find the new shortest route from AA to FF and its length, and state by how much the closure increases the journey.

    (7)

    (Total for Question 5 is 7 marks)

Answer key

Answers begin on a new printed page so the question pack can be completed without the solutions alongside it.

D1-2.1 · The minimum spanning tree (minimum connector) problem. Prim's and Kruskal's algorithm.

Tier 1 · Easy

Mark scheme for D1-2.1 Tier 1 · Easy
QuestionSchemeMarks
1
  • Ascending order: BC=3BC=3, AC=4AC=4, CD=5CD=5, AB=6AB=6, DE=7DE=7, CE=8CE=8, BD=9BD=9
  • Accept BCBC, accept ACAC, accept CDCD
  • Reject ABAB, since it forms the cycle ABCABC
  • Accept DEDE; the tree now has 44 arcs and the algorithm stops
  • Total weight =3+4+5+7=19=3+4+5+7=19
5
(5 marks)5
Notes
Sorting the arcs gives BC,AC,CD,AB,DE,CE,BDBC, AC, CD, AB, DE, CE, BD. Adding BCBC, ACAC and CDCD creates no cycle and connects AA, BB, CC, DD. The next arc ABAB would close the cycle ABCABC, so it is rejected. Then DEDE brings in the last vertex EE, giving 51=45-1=4 arcs, so the algorithm terminates with weight 3+4+5+7=193+4+5+7=19.
2
  • A spanning tree is a subgraph that contains every vertex of the network, is connected and contains no cycles
  • A tree on nn vertices has n1n-1 arcs
  • A spanning tree on 99 vertices has 88 arcs
3
(3 marks)3
Notes
A tree is a connected graph with no cycles, and it is spanning when it includes every vertex of the original network. Building a tree by adding one arc at a time connects one new vertex per arc after the first vertex, so a tree on nn vertices always has exactly n1n-1 arcs; with n=9n=9 that gives 88 arcs.

Tier 2 · Standard

Mark scheme for D1-2.1 Tier 2 · Standard
QuestionSchemeMarks
1
  • Add AC=5AC=5
  • Add CD=6CD=6
  • Add CB=7CB=7
  • Add BE=8BE=8
  • Add EF=4EF=4
  • Order of vertices joined: AA, CC, DD, BB, EE, FF
  • Total weight =5+6+7+8+4=30=5+6+7+8+4=30
6
(6 marks)6
Notes
Starting from AA, the shortest arc out of {A}\{A\} is AC=5AC=5. From {A,C}\{A, C\} the choices are AB=9AB=9, AD=12AD=12, BC=7BC=7, CD=6CD=6, CE=11CE=11, CF=13CF=13, and the shortest is CD=6CD=6. From {A,C,D}\{A, C, D\} the shortest arc to a new vertex is CB=7CB=7, since DF=10DF=10 is longer. From {A,B,C,D}\{A, B, C, D\} the shortest is BE=8BE=8, as CE=11CE=11, CF=13CF=13 and DF=10DF=10 are all longer. Finally EF=4EF=4 brings in FF. The five arcs total 3030.
2
  • Ascending order: EF=4EF=4, AC=5AC=5, CD=6CD=6, BC=7BC=7, BE=8BE=8, AB=9AB=9, DF=10DF=10, CE=11CE=11, AD=12AD=12, CF=13CF=13
  • Accept EFEF, then ACAC, then CDCD, then BCBC, then BEBE
  • Each of those five arcs joins two components that were previously separate, so none of them closes a cycle
  • No arc is rejected: after BEBE the tree has 61=56-1=5 arcs and every vertex is connected, so the algorithm stops
  • The arcs ABAB, DFDF, CECE, ADAD and CFCF are therefore never considered
  • Total weight =4+5+6+7+8=30=4+5+6+7+8=30
6
(6 marks)6
Notes
Sorting gives EF,AC,CD,BC,BE,AB,DF,CE,AD,CFEF, AC, CD, BC, BE, AB, DF, CE, AD, CF. Arc EFEF starts a component {E,F}\{E, F\}; ACAC starts a second one, which CDCD and then BCBC extend to {A,B,C,D}\{A, B, C, D\}; finally BEBE joins those two components together. Every arc taken has its two endpoints in different components at the moment it is tested, so no cycle is ever formed and this network gives the algorithm nothing to reject. After BEBE the tree has 61=56-1=5 arcs spanning all six vertices, so Kruskal's algorithm terminates and ABAB, DFDF, CECE, ADAD and CFCF are never reached. The total weight is 4+5+6+7+8=304+5+6+7+8=30, matching Prim's answer as it must.
3
  • Ascending order begins EF=7EF=7, BC=8BC=8, CD=9CD=9, AC=10AC=10, FG=11FG=11, DF=12DF=12, BE=13BE=13, AB=14AB=14
  • Accept EFEF, BCBC, CDCD, ACAC, FGFG
  • Accept DFDF, joining the two components {A,B,C,D}\{A, B, C, D\} and {E,F,G}\{E, F, G\}
  • The tree now has 66 arcs and every vertex is included, so the algorithm stops
  • Minimum spanning tree: EFEF, BCBC, CDCD, ACAC, FGFG, DFDF
  • Total weight =7+8+9+10+11+12=57=7+8+9+10+11+12=57
6
(6 marks)6
Notes
Taking arcs in ascending order, EF=7EF=7 starts one component and BC=8BC=8 another; CD=9CD=9 and AC=10AC=10 extend the second to {A,B,C,D}\{A, B, C, D\}; FG=11FG=11 extends the first to {E,F,G}\{E, F, G\}. The next arc DF=12DF=12 is the first that joins the two components, and it is accepted. That gives 71=67-1=6 arcs covering all seven vertices, so BEBE, ABAB, CECE, ADAD, EGEG and CFCF are never required. The weight is 7+8+9+10+11+12=577+8+9+10+11+12=57.

Tier 3 · Hard

Mark scheme for D1-2.1 Tier 3 · Hard
QuestionSchemeMarks
1
  • Add AC=10AC=10, joining CC
  • Add CB=8CB=8, joining BB
  • Add CD=9CD=9, joining DD
  • Add DF=12DF=12, joining FF
  • Add FE=7FE=7, joining EE
  • Add FG=11FG=11, joining GG
  • Order of vertices: AA, CC, BB, DD, FF, EE, GG
  • Total weight =10+8+9+12+7+11=57=10+8+9+12+7+11=57, which agrees with Kruskal
7
(7 marks)7
Notes
From {A}\{A\} the arcs available are AB=14AB=14, AC=10AC=10, AD=17AD=17, so ACAC is chosen. From {A,C}\{A, C\} the shortest arc to a new vertex is CB=8CB=8. From {A,B,C}\{A, B, C\} the candidates are AD=17AD=17, CD=9CD=9, BE=13BE=13, CE=16CE=16, CF=21CF=21, so CD=9CD=9 is chosen. From {A,B,C,D}\{A, B, C, D\} the candidates are BE=13BE=13, CE=16CE=16, CF=21CF=21, DF=12DF=12, so DF=12DF=12 is chosen. From {A,B,C,D,F}\{A, B, C, D, F\} the shortest is FE=7FE=7, and finally FG=11FG=11 beats EG=19EG=19. Both algorithms must return the same minimum weight, and 10+8+9+12+7+11=5710+8+9+12+7+11=57 confirms it.
2
  • Prim's algorithm always adds an arc with exactly one endpoint already in the tree
  • The other endpoint is a vertex not yet in the tree, so the new arc cannot close a cycle
  • Kruskal's algorithm takes arcs purely in weight order, so both endpoints may already be in the growing forest
  • That is why every Kruskal arc must be tested for a cycle before it is accepted
  • Kruskal is more convenient when the data arrives as a sorted list of arcs rather than as a full distance matrix or drawn network
5
(5 marks)5
Notes
Prim's algorithm grows one connected tree and only ever considers arcs from a vertex inside the tree to a vertex outside it, so adding such an arc joins a new vertex and leaves a tree. Kruskal's algorithm builds a forest of several components at once, so an arc taken in weight order can have both endpoints in the same component; that arc must be rejected, which is exactly the cycle test. If a problem gives the arcs already listed with their weights, Kruskal needs only a sort and a connectivity check, while Prim would first have to reconstruct which arcs meet each vertex.
3
  • Add DC=6DC=6, joining CC
  • Add CA=5CA=5, joining AA
  • Add CB=7CB=7, joining BB
  • Add BE=8BE=8, joining EE
  • Add EF=4EF=4, joining FF
  • Order of vertices: DD, CC, AA, BB, EE, FF
  • Total weight =6+5+7+8+4=30=6+5+7+8+4=30
  • The minimum spanning tree is a property of the network, not of the start vertex, so the minimum weight is the same wherever Prim begins
7
(7 marks)7
Notes
From {D}\{D\} the arcs are AD=12AD=12, CD=6CD=6, DF=10DF=10, so DCDC is chosen. From {C,D}\{C, D\} the candidates are AC=5AC=5, AD=12AD=12, BC=7BC=7, CE=11CE=11, CF=13CF=13, DF=10DF=10, and CA=5CA=5 wins. From {A,C,D}\{A, C, D\} the shortest arc to a new vertex is CB=7CB=7; then BE=8BE=8; then EF=4EF=4. The arcs selected are the same five as when Prim starts at AA, though in a different order, and the weight is 3030. In general the start vertex changes the order of selection but not the set of minimum-weight trees, because the minimum connector is determined by the arc weights alone.
4
  • Removing the arc of weight 88 splits the tree into two components
  • New weight =308+13=35=30-8+13=35
  • Any spanning tree must contain at least one arc joining the two components
  • The cheapest such arc has weight 1313, so no spanning tree of the reduced network is lighter than 3535
  • An arc with both endpoints in the same component would leave the two parts disconnected
  • Such an arc would create a cycle rather than reconnect the tree, so it cannot be used as the replacement
6
(6 marks)6
Notes
Deleting an arc of a spanning tree always leaves exactly two components. Every spanning tree of the reduced network must include at least one arc across the cut between them, so its weight is at least 30830-8 plus the smallest crossing weight; taking the cheapest crossing arc, of weight 1313, achieves that bound and gives 3535. An arc whose endpoints lie in the same component adds a cycle to that component while leaving the other component unreachable, so it fails the spanning condition and cannot serve as the replacement.
5
  • The arcs BC=3BC=3 and AC=4AC=4 join AA, BB, CC at a cost of 77 and are always chosen
  • The tree must then reach DD and EE
  • Using CDCD, the cheapest completion is CDCD then DEDE, costing k+7k+7
  • Avoiding CDCD, the cheapest completion is CE=8CE=8 then DE=7DE=7, costing 1515
  • Total weight =7+min(k+7,  15)=7+\min(k+7,\;15)
  • CDCD is used when k+7<15k+7<15, that is 0<k<80<k<8, with a tie at k=8k=8
  • For k=10k=10 the minimum spanning tree is BCBC, ACAC, CECE, DEDE of weight 3+4+8+7=223+4+8+7=22
7
(7 marks)7
Notes
The arcs BC=3BC=3 and AC=4AC=4 are the two cheapest and connect AA, BB and CC for 77. Two further arcs must bring in DD and EE. With CDCD available the cheapest pair is CD=kCD=k followed by DE=7DE=7, costing k+7k+7; the alternative CDCD then CE=8CE=8 costs k+8k+8 and is never better. Without CDCD the cheapest pair is CE=8CE=8 followed by DE=7DE=7, costing 1515, which beats BD=9BD=9 with DE=7DE=7 at 1616. The tree weight is therefore 7+min(k+7,15)7+\min(k+7, 15), so CDCD appears exactly while k<8k<8, with both trees weighing 2222 at k=8k=8. At k=10k=10 the arc CDCD is not used and the tree BCBC, ACAC, CECE, DEDE has weight 2222.

D1-2.2 · Dijkstra's and Floyd's algorithm for finding the shortest path.

Tier 1 · Easy

Mark scheme for D1-2.2 Tier 1 · Easy
QuestionSchemeMarks
1
  • AA: order 11, final label 00
  • BB: order 22, final label 44
  • CC: order 33, working values 77 then 66, final label 66
  • DD: order 44, working values 1212 then 99, final label 99
  • EE: order 55, working values 1515 then 1414, final label 1414
  • Shortest path ABCDEABCDE of length 1414
6
(6 marks)6
Notes
Label AA with 00. Its neighbours take working values B=4B=4 and C=7C=7, so BB is labelled second with 44. From BB, CC improves to 4+2=64+2=6 and DD takes 4+8=124+8=12, so CC is labelled third with 66. From CC, DD improves to 6+3=96+3=9 and EE takes 6+9=156+9=15, so DD is labelled fourth with 99. From DD, EE improves to 9+5=149+5=14, so EE is labelled fifth with 1414. Tracing back, 149=5=DE14-9=5=DE, 96=3=CD9-6=3=CD, 64=2=BC6-4=2=BC and 40=4=AB4-0=4=AB, giving the path ABCDEABCDE.
2
  • The order of labelling, the final label, and the working values
  • The final label is the shortest distance from the start vertex
  • A vertex receives a new working value each time a shorter route to it is found from a newly labelled vertex, so several working values can accumulate before the smallest becomes final
3
(3 marks)3
Notes
The box records, in order, when the vertex was made permanent, the shortest distance to it from the start, and every trial distance found on the way. Each time a vertex is given a final label, all of its unlabelled neighbours are offered the new final label plus the connecting arc; whenever that offer beats the values already written, it is added to the list. The last, smallest working value becomes the final label.

Tier 2 · Standard

Mark scheme for D1-2.2 Tier 2 · Standard
QuestionSchemeMarks
1
  • AA: order 11, final 00
  • BB: order 22, final 55
  • CC: order 33, working 88 then 77, final 77
  • DD: order 44, working 1414 then 1111, final 1111
  • EE: order 55, working 1414, final 1414
  • FF: order 66, working 1717, final 1717
  • Shortest route ABCDFABCDF of length 1717
7
(7 marks)7
Notes
Labelling AA with 00 offers B=5B=5 and C=8C=8, so BB is made final at 55. From BB, CC improves to 5+2=75+2=7 and DD takes 5+9=145+9=14; CC becomes final at 77. From CC, DD improves to 7+4=117+4=11 and EE takes 7+7=147+7=14; DD becomes final at 1111. From DD, FF takes 11+6=1711+6=17, and EE at 1414 is smaller, so EE becomes final at 1414. From EE, FF would be 14+4=1814+4=18, which does not beat 1717, so FF is final at 1717. Tracing back, 1711=6=DF17-11=6=DF, 117=4=CD11-7=4=CD, 75=2=BC7-5=2=BC and 50=5=AB5-0=5=AB, giving ABCDFABCDF.
2
  • EE: working values 1818 then 1717, final label 1717
  • FF: working values 2323, then 2121, then 2020, final label 2020
  • GG: working values 3232 then 2727, final label 2727
  • The order of labelling is AA, BB, CC, DD, EE, FF, GG
7
(7 marks)7
Notes
The first four final labels are A=0A=0, B=6B=6, C=9C=9 and D=11D=11. From BB, EE takes 6+12=186+12=18; from CC, EE improves to 9+8=179+8=17 and FF takes 9+14=239+14=23; from DD, FF improves to 11+10=2111+10=21. The smallest working value is now E=17E=17, which becomes final; from EE, FF improves to 17+3=2017+3=20 and GG takes 17+15=3217+15=32. Then F=20F=20 becomes final and offers GG the value 20+7=2720+7=27, which beats 3232, so GG is final at 2727.
3
  • Initial distances, with rows and columns in the order AA, BB, CC, DD: row AA is 0,7,,40, 7, -, 4; row BB is 7,0,3,7, 0, 3, -; row CC is ,3,0,2-, 3, 0, 2; row DD is 4,,2,04, -, 2, 0, where a dash means no direct arc
  • Initial route matrix: every entry in column AA is AA, in column BB is BB, in column CC is CC and in column DD is DD
  • Iteration 11 uses k=Ak=A
  • dBDd_{BD} becomes dBA+dAD=7+4=11d_{BA}+d_{AD}=7+4=11, and rBDr_{BD} becomes rBA=Ar_{BA}=A
  • dDBd_{DB} becomes dDA+dAB=4+7=11d_{DA}+d_{AB}=4+7=11, and rDBr_{DB} becomes rDA=Ar_{DA}=A
  • No other entry improves on iteration 11
6
(6 marks)6
Notes
The distance matrix records the direct arc weights with zeros on the diagonal and a dash where no arc exists; the route matrix starts with column jj filled entirely with the label jj. Iteration 11 tests every dijd_{ij} against diA+dAjd_{iA}+d_{Aj}. The only entries that are currently missing and can be filled through AA are BDBD and DBDB, each becoming 7+4=117+4=11, and their route entries are set to rBA=Ar_{BA}=A and rDA=Ar_{DA}=A respectively. Entries such as dBC=3d_{BC}=3 are already shorter than any route through AA, so they are unchanged.

Tier 3 · Hard

Mark scheme for D1-2.2 Tier 3 · Hard
QuestionSchemeMarks
1
  • Final distances, rows and columns in the order AA, BB, CC, DD: row AA is 0,7,6,40, 7, 6, 4; row BB is 7,0,3,57, 0, 3, 5; row CC is 6,3,0,26, 3, 0, 2; row DD is 4,5,2,04, 5, 2, 0
  • Final routes: row AA is A,B,D,DA, B, D, D; row BB is A,B,C,CA, B, C, C; row CC is D,B,C,DD, B, C, D; row DD is A,C,C,DA, C, C, D
  • Shortest route from AA to CC: rAC=Dr_{AC}=D, then rDC=Cr_{DC}=C, giving ADCADC of length 66
  • Shortest route from BB to DD: rBD=Cr_{BD}=C, then rCD=Dr_{CD}=D, giving BCDBCD of length 55
8
(8 marks)8
Notes
Iteration k=Ak=A fills dBD=dDB=11d_{BD}=d_{DB}=11 with route entry AA. Iteration k=Bk=B gives dAC=dAB+dBC=7+3=10d_{AC}=d_{AB}+d_{BC}=7+3=10 with rAC=rAB=Br_{AC}=r_{AB}=B, and symmetrically dCA=10d_{CA}=10 with rCA=Br_{CA}=B. Iteration k=Ck=C gives dBD=dBC+dCD=3+2=5d_{BD}=d_{BC}+d_{CD}=3+2=5, improving on 1111, with rBD=rBC=Cr_{BD}=r_{BC}=C, and symmetrically dDB=5d_{DB}=5 with rDB=Cr_{DB}=C. Iteration k=Dk=D gives dAC=dAD+dDC=4+2=6d_{AC}=d_{AD}+d_{DC}=4+2=6, improving on 1010, with rAC=rAD=Dr_{AC}=r_{AD}=D, and symmetrically dCA=6d_{CA}=6 with rCA=Dr_{CA}=D. Reading the route matrix, AA to CC goes first to DD and then DD to CC goes direct, so the route is ADCADC; BB to DD goes first to CC and then direct, giving BCDBCD.
2
  • Dijkstra makes final the vertex with the smallest working value at each stage
  • All arc weights are non-negative, so no route discovered later can be shorter than a label already made final
  • Once the destination is made final its label cannot improve, so the algorithm may stop
  • Floyd improves entries only by routing through the vertex kk of the current iteration
  • A shortest route may pass through a vertex whose iteration has not yet been run
  • Omitting iteration kk would leave every improvement that uses kk undiscovered, so all nn iterations are needed
6
(6 marks)6
Notes
Dijkstra's correctness rests on non-negative weights: the smallest outstanding working value cannot be beaten by extending any longer route, so making it final is safe and the destination's label is already optimal when it is made final. Floyd's algorithm, by contrast, considers intermediate vertices one at a time, and after iteration kk the matrix holds the shortest routes that use only AA to kk as intermediates. A route that passes through a later vertex is simply not yet representable, so the algorithm has no valid stopping point before the final iteration.
3
  • Shortest route ACEFGACEFG of length 2727
  • Check: 9+8+3+7=279+8+3+7=27
  • The best route to GG avoiding EFEF goes AA, DD, FF, GG
  • Its length is 11+10+7=2811+10+7=28
  • The route ACEFGACEFG has length 24+x24+x when EF=xEF=x
  • It remains shortest while 24+x2824+x\leqslant28, that is x4x\leqslant4
  • EFEF may be lengthened by at most 43=14-3=1
8
(8 marks)8
Notes
Dijkstra from AA gives final labels A=0A=0, B=6B=6, C=9C=9, D=11D=11, E=17E=17, F=20F=20, G=27G=27, and tracing back through 2720=7=FG27-20=7=FG, 2017=3=EF20-17=3=EF, 179=8=CE17-9=8=CE and 90=9=AC9-0=9=AC gives ACEFGACEFG. If EFEF is changed to xx the length of that route becomes 9+8+x+7=24+x9+8+x+7=24+x. Every route to GG finishes with FG=7FG=7 or EG=15EG=15. The best route reaching FF without using EFEF is ADFADF, of length 11+10=2111+10=21, which beats ACDFACDF at 9+5+10=249+5+10=24, so the best rival through FF is 2828; the best route using EGEG is ACEACE then EGEG, of length 17+15=3217+15=32. The binding rival is therefore 2828, and ACEFGACEFG stays shortest while 24+x2824+x\leqslant28, that is x4x\leqslant4, an increase of at most 11.
4
  • The difference of the final labels is 1912=719-12=7, which equals the weight of CECE
  • So there is a shortest route to EE whose last arc is CECE
  • The route to EE is a shortest route to CC followed by the arc CECE
  • Another vertex XX could satisfy the same equality, with final label of EE minus final label of XX equal to the weight of XEXE
  • In that case there are two shortest routes to EE of equal length, so CC need not lie on every one
5
(5 marks)5
Notes
The trace-back rule is that an arc XYXY lies on a shortest route to YY exactly when the final label of YY minus the final label of XX equals the weight of XYXY; here 1912=719-12=7 confirms that CECE is such an arc, so appending CECE to any shortest route to CC gives a shortest route to EE. The rule identifies one valid predecessor, not a unique one: if some other vertex also satisfies the equality, the network has two distinct shortest routes to EE of the same total length, and the trace-back would legitimately produce either.
5
  • With CC available the shortest route is ABCDFABCDF of length 1717
  • Deleting CC removes the arcs ACAC, BCBC, CDCD and CECE
  • The only remaining arcs are AB=5AB=5, BD=9BD=9, DF=6DF=6 and EF=4EF=4
  • EE is now reachable only through FF, so no route to FF can use EE
  • The only route from AA to FF is ABDFABDF
  • Its length is 5+9+6=205+9+6=20
  • The closure adds 2017=320-17=3 to the journey
7
(7 marks)7
Notes
Removing CC also removes every arc incident to it, leaving only ABAB, BDBD, DFDF and EFEF. From AA the sole first step is AB=5AB=5; from BB the sole onward step is BD=9BD=9; from DD the sole onward step is DF=6DF=6. The vertex EE now hangs off FF alone, so it cannot appear on a route into FF. The unique route is therefore ABDFABDF of length 2020, which is 33 more than the original shortest route ABCDFABCDF of length 1717.