9618/32/O/N/23 question 8: worked solution (October/November 2023, paper 32)
Show as plain textHide plain text
Cambridge A2 Level Computer Science 9618 · 19.1 Algorithms Worked solution from the Computational thinking and Problem-solving Paper 3 Advanced Theory booklet, Part 1 of 2. Q11 9618/32/O/N/23 original Q8 Structured · 5 marks 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. Visit Distance found Start 0 A = 8, F = 10 A 8 B = 12 F 10 C = 19, E = 17 B 12 D = 14, C = 20 (not better than 19) D 14 E = 16 (better than 17) E 16 C = 19 (same as before) C 19 all 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: A B C D E F 8 12 19 14 16 10 All six values correct [2] Four or five values correct earns 1 mark instead. KEY IDEA Dijkstra always visits the nearest unvisited node and updates its neighbours with the shorter route. TOTAL 5 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by TEACHING BY SM. Tap the picture to open it on YouTube.