Maths topics › A level Further Maths › D1, algorithms and graphs
Find the shortest distances and routes between all pairs of vertices using Floyd's algorithm
A question
Free worksheet
10 questions on this objective, ready to print.
Download the worksheet (PDF)Worked solution
The working
- (a) In iteration 1, each entry is compared with (row entry in column \(A\)) + (column entry in row \(A\)). For row B, column E this gives \(25\), which is less than a dash, so it is replaced. After the first iteration:
A B C D E A – 13 4 20 12 B 13 – 17 5 25 C 4 17 – 15 9 D 20 5 15 – 4 E 12 25 9 4 – - (b) The route table entry becomes the entry in column \(A\) of row B, which is \(A\): go to \(A\) first.
- (c) One iteration for each place: \(5\).
- (d) The final distance table is
A B C D E A – 13 4 16 12 B 13 – 17 5 9 C 4 17 – 13 9 D 16 5 13 – 4 E 12 9 9 4 – - so the shortest distance from B to C is \(17\).
- (e) The shortest route is BAC, so the first place to go to from B is A.
Mathster is maths homework, practice and assessment for schools, with animated worked solutions. Try Mathster free for 60 days →
Objectives from the AS and A level subject content for further mathematics (Department for Education). Contains public sector information licensed under the Open Government Licence v3.0.