Cambridge AS Level Computer Science 9618 · 12.2 Program Design

Q31 · 9618/22/O/N/25 Q7

Worked solution from the Software Development Paper 2 Problem-solving and Programming booklet, Part 2 of 3.

Q319618/22/O/N/25original Q7Structured · 6 marks
Question 7 from 9618/22/O/N/25

Worked solution

(a)

Write what the curved arrow shows, using the module names:

It shows repetition (iteration) [1]

Convert repeatedly calls Analyse, then Update, then Sort, in that order [1]

(b)

Count goes into Analyse and does not come back, so it is a procedure. Update takes Key (STRING) and gives back T1 (the number of elements, so INTEGER), so it is a function. P2 has a filled circle (a flag, so BOOLEAN) and goes both ways, so it is passed by reference.

PROCEDURE Analyse(Count : INTEGER)
FUNCTION Update(Key : STRING) RETURNS INTEGER
PROCEDURE Sort(BYREF P2 : BOOLEAN)

Analyse as a PROCEDURE with parameter Count : INTEGER [1]

Update as a FUNCTION with parameter Key : STRING [1]

Update RETURNS INTEGER [1]

Sort as a PROCEDURE with BYREF P2 : BOOLEAN [1]

KEY IDEARead a structure chart to decide procedure or function, then write each header with its parameters, BYREF where the data goes both ways, and RETURNS where a value comes back.
TOTAL 6 marks

Official mark scheme

Mark scheme for 9618/22/O/N/25 question 7
VIDEO
▶ Whole paper

Video solution of the whole paper · by MAK CS. 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.