9618/21/M/J/24 question 2: worked solution (May/June 2024, paper 21)

Show as 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. Q35 9618/21/M/J/24 original Q2 Structured · 7 marks Worked solution (a) Fill the five empty shapes like this: First box (after START): set Tries to 0 and Count to 0 [1] Box under INPUT A, B: set Tries to Tries + 1 [1] Decision: is A > B ? If Yes, the next box is: set Count to Count + 1; if No, go back to the input [1] Decision: is Count = 10 ? Label the branches Yes and No ; No goes back to the input [1] Output parallelogram (Yes branch): OUTPUT Tries [1] (b) ThisSequence is a string (for example "67,72") that is input in one go [1] A special separator character (such as a comma) goes between the numbers, so the program can find it and split the string to pull out each number (or every number has a fixed length) [1] KEY IDEA Use one counter for every input and a second counter for the event you are waiting for. TOTAL 7 marks Official mark scheme VIDEO ▶ Starts at Q2 (13:56) Starts at Q2 (13:56) · by Pseudocode Pro. Tap the picture to open it on YouTube.