Worked solution from the Artificial Intelligence (AI) Paper 3 Advanced Theory booklet, Part 1 of 1.
Dijkstra's algorithm: give the start town (Base) a distance of 0 and every other town a distance of ∞. Then repeatedly visit the unvisited town with the smallest distance and update its neighbours.
Working: Base = 0; Town 1 = ∞, Town 2 = ∞, Town 3 = ∞, Town 4 = ∞, Town 5 = ∞, Town 6 = ∞.
Write: Base set to 0 and all other towns set to ∞ [1]
Visit Base. Update: Town 1 = 4, Town 2 = 5, Town 3 = 2. Visit Town 3 (smallest, 2). Update: Town 1 = 2 + 1 = 3 (better than 4), Town 5 = 2 + 1 = 3. Visit Town 1 (3): Town 4 = 3 + 7 = 10. Visit Town 5 (3): Town 2 = 3 + 3 = 6 (worse than 5, keep 5), Town 4 = 3 + 6 = 9 (better than 10), Town 6 = 3 + 5 = 8. Visit Town 2 (5): Town 6 = 5 + 8 = 13 (worse than 8, keep 8).
Write: values at the nodes updated and visited nodes shown [1]
Write: more than one route worked out for at least one town, for example Town 4 = 10 or 9, Town 6 = 13 or 8, Town 1 = 4 or 3 [1]
| Town 1 | Town 2 | Town 3 | Town 4 | Town 5 | Town 6 |
|---|---|---|---|---|---|
| 3 | 5 | 2 | 9 | 3 | 8 |
Four of the six values correct [1]
All six values correct [1]
Write any three of these points:
Graphs give a structure that shows relationships between nodes (for example places and the links between them). [1]
An AI problem can be defined or solved as finding a path in a graph. [1]
Graphs can be used by algorithms such as A* or Dijkstra's algorithm, which are used in machine learning. [1]
Also accepted: artificial neural networks can be shown as graphs, and methods such as back propagation of errors or regression work on them.
▶ 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.