9618/23/O/N/25 question 2: worked solution (October/November 2025, paper 23)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 9.2 Algorithms Worked solution from the Algorithm Design and Problem-solving Paper 2 Problem-solving and Programming booklet, Part 2 of 2. Q46 9618/23/O/N/25 original Q2 Structured · 8 marks Worked solution (a) Write the steps in words, not pseudocode. Any six of these: Open the text file in append mode (and close it after the loop) [1] Set a variable to 1 to use as the array index [1] Use the variable as the index to get an element of the array, in a loop [1] Test whether the element is blank (an empty string) [1] If it is not blank , write it to the file on a new line [1] Add 1 to the variable [1] Repeat until all 65 elements have been checked. This step earns no extra mark: any 6 of these 7 points score. (b) Construct: Selection (an IF statement) [1] Use: to test whether the array element is blank before writing it [1] Another answer that scores: Sequence – the steps must be carried out in the correct order for the task to work. KEY IDEA Stepwise refinement breaks the task into small ordered steps: open, loop, test, write, move on. TOTAL 8 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by Craig'n'Dave. Tap the picture to open it on YouTube.