Cambridge A2 Level Computer Science 9618 · 19.1 Algorithms

Q11 · 9618/32/O/N/23 Q8

Worked solution from the Computational thinking and Problem-solving Paper 3 Advanced Theory booklet, Part 1 of 2.

Q119618/32/O/N/23original Q8Structured · 5 marks
Question 8 from 9618/32/O/N/23

Worked solution

Working

Dijkstra: give Start 0 and every other node infinity. Always visit the unvisited node with the smallest distance, then update its neighbours.

VisitDistance found
Start 0A = 8, F = 10
A 8B = 12
F 10C = 19, E = 17
B 12D = 14, C = 20 (not better than 19)
D 14E = 16 (better than 17)
E 16C = 19 (same as before)
C 19all done

Start set to 0 and the other nodes set to infinity [1]

Values updated and visited nodes shown [1]

More than one route worked out for a node and the shortest kept (for example E via F is 17, via D is 16) [1]

Answers

Write the shortest distance from Start:

ABCDEF
81219141610

All six values correct [2]

Four or five values correct earns 1 mark instead.

KEY IDEADijkstra always visits the nearest unvisited node and updates its neighbours with the shorter route.
TOTAL 5 marks

Official mark scheme

Mark scheme for 9618/32/O/N/23 question 8
VIDEO
▶ Whole paper

Video solution of the whole paper · by TEACHING BY SM. 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.