Cambridge A2 Level Computer Science 9618 · 18.1 Artificial Intelligence (AI)

Q16 · 9618/33/O/N/25 Q8

Worked solution from the Artificial Intelligence (AI) Paper 3 Advanced Theory booklet, Part 1 of 1.

Q169618/33/O/N/25original Q8Structured · 5 marks
Question 8 from 9618/33/O/N/25

Worked solution

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:

VisitedTVWXYZ
Start6∞∞∞22∞
T (6)610∞∞22∞
V (10)610131922∞
W (13)610131822∞
X (18)61013182128
Y (21)61013182128

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:

TVWXYZ
61013182128

Four or five answers correct scores 1 mark; all six answers correct [2]

KEY IDEADijkstra's always visits the nearest unvisited node and updates its neighbours with the shorter total distance.
TOTAL 5 marks

Official mark scheme

Mark scheme for 9618/33/O/N/25 question 8
VIDEO
▶ 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.