Worked solution from the Artificial Intelligence (AI) Paper 3 Advanced Theory booklet, Part 1 of 1.
Start at Start with distance 0 and set every other node to infinity (∞). Initialisation [1]
Update the neighbours of Start: T = 6 and Y = 22. Mark Start as visited. Values are updated and visited nodes are shown [1]
Visit the smallest unvisited node each time and update its neighbours:
| Visited | T | V | W | X | Y | Z |
|---|---|---|---|---|---|---|
| Start | 6 | ∞ | ∞ | ∞ | 22 | ∞ |
| T (6) | 6 | 10 | ∞ | ∞ | 22 | ∞ |
| V (10) | 6 | 10 | 13 | 19 | 22 | ∞ |
| W (13) | 6 | 10 | 13 | 18 | 22 | ∞ |
| X (18) | 6 | 10 | 13 | 18 | 21 | 28 |
| Y (21) | 6 | 10 | 13 | 18 | 21 | 28 |
Route to X is worked out two ways: V → X = 10 + 9 = 19, but W → X = 13 + 5 = 18, so keep 18. Y: 18 + 3 = 21 is less than 22. Z: 18 + 10 = 28 is less than 21 + 8 = 29. More than one route calculated for a node [1]
Write the answers in the table:
| T | V | W | X | Y | Z |
|---|---|---|---|---|---|
| 6 | 10 | 13 | 18 | 21 | 28 |
Four or five answers correct scores 1 mark; all six answers correct [2]
▶ Topic lesson
A lesson on this topic · by The CS Classroom. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.