Topic Test
Pearson Edexcel GCE Mathematics
(9FM0)
Paper 3D Decision Mathematics 1
Dijkstra’s and Floyd’s Algorithms -
Questions
Pearson: helping people progress, everywhere
Pearson aspires to be the world’s leading learning company. Our aim is to help everyone progress in their lives
through education. We believe in every kind of learning, for all kinds of people, wherever they are in the
world. We’ve been involved in education for over 150 years, and by working across 70 countries, in 100
languages, we have built an international reputation for our commitment to high standards and raising
achievement through innovation in education. Find out more about how we can help you and your students
at: www.pearson.com/uk
© Pearson Education Ltd 2024
About this topic test
This topic test is comprised from legacy past paper questions (prior
to 2019) and some BRAND NEW question parts (see list below)
2
5
7
9
The exam questions have been selected for the topic of Dijkstra’s
and Floyd’s Algorithms with the intention of being used in
isolation, however some inherent overlap between topics may
occur.
The questions within this topic test have been ordered in terms of
difficulty, from ‘easiest’ to ‘hardest’.
The total number of marks for this topic test is 100 marks.
1. Figure 1
A B C D
4 6 6
1 2 8 4
E F G
H
4 5 2
5 7 3 1
I 2 J 4 K 1 L
Figure 1 shows a network of roads. Erica wishes to travel from A to L as quickly as possible.
The number on each edge gives the time, in minutes, to travel along that road.
(a) Use Dijkstra’s algorithm to find a quickest route from A to L. Complete all the boxes on
the answer sheet and explain clearly how you determined the quickest route from your
labelling.
(7)
(b) Show that there is another route which also takes the minimum time.
(1)
(Total 8 marks)
___________________________________________________________________________
4 © Pearson Education Ltd 2024
2.
4 10
16
A C
2 3
Figure 2
The network in Figure 2 shows the roads linking four villages, A, B, C and D. The weight on
each arc is the time, in minutes, it takes to travel along the corresponding road. The road from
D to A is one way as indicated by the arrow on the corresponding arc.
Floyd’s algorithm is to be used to find the complete network of shortest times between the
four villages.
(a) Set up the initial time and route matrices.
(2)
(b) Use Floyd’s algorithm to find a table of least distances. You should show both the
distance table and the route table after each iteration.
(8)
(c) Explain how the final route table can be used to find the shortest route from C to B. State
this route.
(3)
(Total 13 marks)
___________________________________________________________________________
5 © Pearson Education Ltd 2024
3.
C
20 16
G
A
26 12
34 11
D
S 24 33 T
22
B 21 18
25
E H
34
10
Figure 3
(a) Use Dijkstra’s algorithm to find the shortest route from S to T in Figure 3. Show all
necessary working in the boxes in the answer booklet.
State your shortest route and its length.
(6)
(b) Explain how you determined the shortest route from your labelling.
(2)
(c) It is now necessary to go from S to T via H. Obtain the shortest route and its length.
(2)
(Total 10 marks)
6 © Pearson Education Ltd 2024
4.
Figure 4
Figure 4 shows a network of roads. The number on each arc represents the length of that road
in km.
(a) Use Dijkstra’s algorithm to find the shortest route from A to J. State your shortest route
and its length.
(5)
(b) Explain how you determined the shortest route from your labelled diagram.
(2)
The road from C to F will be closed next week for repairs.
(c) Find the shortest route from A to J that does not include CF and state its length.
(3)
(Total 10 marks)
7 © Pearson Education Ltd 2024
5.
A 10 B
31
12 21
15
F 4 C
6
24
22 8
9
E D
11
Figure 5
The rail network connecting 6 towns, A, B, C, D, E and F is represented in Figure 5. The
weight on each arc is the time in minutes a train takes to travel between the two towns.
The initial time matrix is shown below.
A B C D E F
A – 10 15 6 4 12
B 10 – 21 24 ∞ 31
C 15 21 – 8 ∞ ∞
D 6 24 8 – 11 9
E 4 ∞ ∞ 11 – 22
F 12 31 ∞ 9 22 –
(a) State which feature of the matrix indicates that the network is undirected.
(1)
(b) Perform the first two iterations of Floyd’s algorithm. You should show the time matrix
after each iteration.
(3)
8 © Pearson Education Ltd 2024
After Floyd’s algorithm is completed the final distance table and completed final route table
are shown below.
Final time matrix Final route matrix
A B C D E F A B C D E F
A – 10 14 6 4 12 A A B D D E F
B 10 – 21 16 14 22 B A B C A A A
C 14 21 – 8 18 17 C D B C D D D
D 6 16 8 – 10 9 D A A C D A F
E 4 14 18 10 – 16 E A A D A E A
F 12 22 17 9 16 – F A A D D A F
(c) Explain how the final route table can be used to find the shortest route from C to E. State
this route.
(3)
A tourist wishes to use the rail network to visit all 6 towns on the network starting and
finishing at A.
(d) (i) Use the nearest neighbour algorithm, starting at A, to find a Hamiltonian cycle in the
complete network of shortest times.
(ii) Find the time taken for this cycle.
(iii) Interpret the cycle in terms of the actual towns visited.
(3)
(Total 10 marks)
___________________________________________________________________________
9 © Pearson Education Ltd 2024
6.
Figure 6
Figure 6 shows the network of paths in a country park. The number on each path gives its
length in km. The vertices A and I represent the two gates in the park and the vertices B, C, D,
E, F, G and H represent places of interest.
(a) Use Dijkstra’s algorithm to find the shortest route from A to I. Show all necessary
working in the boxes in the answer booklet and state your shortest route and its length.
(5)
The park warden wishes to check each of the paths to check for frost damage. She has to
cycle along each path at least once, starting and finishing at A.
(b) (i) Use an appropriate algorithm to find which paths will be covered twice and state
these paths.
(ii) Find a route of minimum length.
(iii) Find the total length of this shortest route.
(5)
(Total 10 marks)
10 © Pearson Education Ltd 2024
7. The initial time matrix (Table 1) shows the time, in minutes, taken by a network of buses
connecting 5 buildings, A, B, C, D and E, in a university. Some of the buses run one-way
only.
A B C D E
A – 3 5 9 7
B 3 – 6 ∞ 12
C 5 6 – 16 ∞
D 9 ∞ 16 – 1
E 7 12 ∞ ∞ –
Table 1
(a) By adding arcs from vertex E, along with their weights, complete the drawing of this
network on Diagram 1 in the answer book.
(1)
Floyd’s algorithm is to be used to find the complete network of shortest times between the
five buildings.
The distance matrix and route matrix after three iterations of Floyd’s algorithm are shown in
Table 2 and Table 3 respectively.
Time matrix Route matrix
A B C D E A B C D E
A – 3 5 9 7 A A B C D E
B 3 – 6 12 10 B A B C A A
C 5 6 – 14 12 C A B C A A
1 D A A A D E
D 9 12 – 1
4
E A A A A E
1
E 7 10 16 – Table 3
2
Table 2
(b) Perform the next two iterations of Floyd’s algorithm that follow from Tables 2 and 3.
You should show the distance and route matrix after each iteration.
(3)
Steph wishes to visit all the university buildings. Starting as A, she applies the nearest
neighbour algorithm to the final time table.
(c) (i) Use the nearest neighbour algorithm, starting at A, to find a Hamiltonian cycle in the
complete network of shortest times.
(ii) Find the time taken for this cycle.
(iii) Interpret the cycle in terms of the actual buildings visited.
11 © Pearson Education Ltd 2024
(iv) Prove that Steph’s cycle is not optimal.
(4)
(Total 8 marks)
8.
Figure 7
Figure 7 shows a network of roads. The number on each arc represents the length, in km, of
that road.
(a) Use Dijkstra’s algorithm to find the shortest route from A to I. State your shortest route
and its length.
(5)
Sam has been asked to inspect the network and assess the condition of the roads. He must
travel along each road at least once, starting and finishing at A.
(b) Use an appropriate algorithm to determine the length of the shortest route Sam can travel.
State a shortest route.
(4)
(The total weight of the network is 197 km.)
(Total 9 marks)
12 © Pearson Education Ltd 2024
9.
A 4 B
8 11
12
F 5 C
10
E D
3
Figure 8
[The total weight of the network is 59]
Direct roads between six cities, A, B, C, D, E and F, are represented in Figure 8. The weight
on each arc is the time, in hours, required to travel along the corresponding road.
Floyd’s algorithm is to be used to find the complete network of shortest times between the six
cities.
The time matrix after three iterations of Floyd’s algorithm is shown in the table 4.
A B C D E F
A – 4 15 21 5 8
B 4 – 11 17 9 12
C 15 11 – 6 10 23
D 21 17 6 – 3 29
E 5 9 10 3 – 13
F 8 12 23 29 13 –
Table 4
(a) Complete the remaining iterations of Floyd’s algorithm that follow from Table 4. You
should show the time matrix after each iteration.
(5)
13 © Pearson Education Ltd 2024
Zion needs to check the condition of each of the roads. He needs to traverse each road at least
once starting and finishing at F. A route which minimises the time taken is required.
(b) (i) Use an appropriate algorithm to find the roads that will need to be traversed twice.
You should make your method and working clear.
(ii) Write down the length of the route.
(5)
Zion decides that he does not need to return to F. A route which minimises the time taken is
required but it may now finish at any city.
(c) Determine in which city Zion’s route should finish. You must give reason’s for your
answer.
(2)
(Total 12 marks)
___________________________________________________________________________
14 © Pearson Education Ltd 2024
10.
Figure 9
Peter wishes to minimise the time spent driving from his home H, to a campsite at G.
Figure 9 shows a number of towns and the time, in minutes, taken to drive between them. The
volume of traffic on the roads into G is variable, and so the length of time taken to drive
along these roads is expressed in terms of x, where x 0.
(a) On the diagram in the answer book, use Dijkstra’s algorithm to find two routes from H
to G (one via A and one via B) that minimise the travelling time from H to G. State the
length of each route in terms of x.
(7)
(b) Find the range of values of x for which Peter should follow the route via A.
(3)
(Total 10 marks)
TOTAL FOR PAPER: 100 MARKS
15 © Pearson Education Ltd 2024