Cambridge AS Level Computer Science 9618 · 9.2 Algorithms

Q35 · 9618/21/M/J/24 Q2

Worked solution from the Algorithm Design and Problem-solving Paper 2 Problem-solving and Programming booklet, Part 2 of 2.

Q359618/21/M/J/24original Q2Structured · 7 marks
Question 2 from 9618/21/M/J/24

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 IDEAUse one counter for every input and a second counter for the event you are waiting for.
TOTAL 7 marks

Official mark scheme

Mark scheme for 9618/21/M/J/24 question 2
VIDEO
▶ Starts at Q2 (13:56)

Starts at Q2 (13:56) · by Pseudocode Pro. Tap the picture to open it on YouTube.

Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.