9618/22/O/N/25 question 4: worked solution (October/November 2025, paper 22)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 10.2 Arrays Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 2 of 4. Q40 9618/22/O/N/25 original Q4 Structured · 13 marks Worked solution (a) The highest score is 5 × 3 + 4 × 5 = 35, so the array needs indexes 0 to 35. DECLARE CheckTotal : ARRAY[0:35] OF BOOLEAN DECLARE Index : INTEGER FOR Index ← 0 TO 35 CheckTotal[Index] ← FALSE NEXT Index CheckTotal array declared [1] Loop counter declared [1] Loop with correct syntax and 36 passes (0 to 35) [1] Each array element assigned FALSE [1] (b) Easy questions score 0, 3, 6 ... 15 (step 3). Hard questions score 0, 5, ... 20 (step 5). The total is the two added. DECLARE EasyQ, HardQ : INTEGER FOR EasyQ ← 0 TO 15 STEP 3 FOR HardQ ← 0 TO 20 STEP 5 CheckTotal[HardQ + EasyQ] ← TRUE NEXT HardQ NEXT EasyQ EasyQ starts at 0 [1] EasyQ STEP 3 [1] HardQ loop ends at 20 [1] HardQ STEP 5 [1] Index is HardQ + EasyQ (or EasyQ + HardQ) [1] (c) Write the steps in words: Step 1: check that the score is between 0 and 35 [1] Step 2: if it is not, return FALSE [1] Step 3: use the score as the index into CheckTotal [1] Step 4: return the value stored at that index (TRUE or FALSE) [1] KEY IDEA Use nested loops to build every possible total once, then check a score with a direct array lookup. TOTAL 13 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by MAK CS. Tap the picture to open it on YouTube.