9618/21/O/N/25 question 2: worked solution (October/November 2025, paper 21)
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. Q44 9618/21/O/N/25 original Q2 Structured · 5 marks Worked solution Draw a loop that checks each of the 30 elements, with a counter for the number output: START → Set Index to 1 and Count to 0 → decision "Is Index = 31?" If NO: decision "Is Data[Index] = ""?" If YES (blank): Set Index to Index + 1 and go back. If NO: Set Count to Count + 1 → Output Data[Index] → Set Index to Index + 1 → back to the first decision. If YES: Output Count → END. Index and Count both set before the loop [1] Loop that goes through exactly 30 elements [1] Test for an empty string (or a non-empty one) in the current element [1] Count increased when the element is not blank, inside the loop [1] Both outputs (each non-blank element in the loop, and Count after it) under the correct conditions [1] Testing for the empty string first is also accepted. KEY IDEA Initialise the index and count, loop through the array, test each element, count and output the non-blank ones, then output the count. TOTAL 5 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by CSFeedbySirNisarAli. Tap the picture to open it on YouTube.