Computer Science (9608) · Oct/Nov 2021 · PM 41

Cambridge Computer Science (9608) pm for paper 41, Oct/Nov 2021 — 9608/41/O/N/21, file 9608_w21_pm_41.pdf.

Advertisement
Loading the paper…
Text of this paper

Cambridge International AS & A Level
COMPUTER SCIENCE
Paper 4 Further Problem-solving and Programming Skills

9608/41
October/November 2021

PRE-RELEASE MATERIAL
* 7 7 5 7 5 0 0 1 9 8 *

No additional materials are needed.
This material should be given to the relevant teachers and candidates as soon as it has been
received at the centre.
INSTRUCTIONS
●
You should use this material in preparation for the examination.
●
You should attempt the practical programming tasks using your chosen high-level, procedural
programming language.

This document has 8 pages. Any blank pages are indicated.
DC (CJ/SW) 212834/2
© UCLES 2021

[Turn over

2
Teachers and candidates should read this material prior to the November 2021 examination for 9608
Paper 4.
Reminders
The syllabus states:

•
•

there will be questions on the examination paper which do not relate to this pre-release material
you must choose a high-level programming language from:
Visual Basic (console mode)
Python
Pascal / Delphi (console mode).

Note: A mark of zero will be awarded if a programming language other than those listed is used.
The practical skills for Paper 4 build on the practical skills covered in Paper 2. We recommend that
candidates choose the same high-level programming language for this paper as they did for Paper
2. This will give candidates the opportunity for extensive practice and allow them to acquire sufficient
expertise.
Questions on the examination paper may ask the candidate to write:

•
•
•

structured English
pseudocode
program code.

A program flowchart should be considered as an alternative to pseudocode for documenting a highlevel algorithm design.
Candidates should be confident with:

•
•

the presentation of an algorithm using either a program flowchart or pseudocode
the production of a program flowchart from given pseudocode and vice versa.

Candidates will also benefit from using pre-release materials from previous examinations.
These are available on the teacher support site.
Declaration of variables
The syllabus document shows the syntax expected for a declaration statement in pseudocode.
DECLARE <identifier> : <data type>
If Python is the chosen language, each variable’s identifier (name) and its intended data type must be
documented using a comment statement.
Structured English – Variables
An algorithm in pseudocode uses variables, which should be declared. An algorithm in structured
English does not always use variables. In this case, the candidate needs to use the information given
in the question to complete an identifier table. The table needs to contain an identifier, data type and
description for each variable.

© UCLES 2021

9608/41/PRE/O/N/21

3
TASK 1 – Recursion
Iterative algorithms can be written as recursive algorithms and vice versa.
TASK 1.1
Research the advantages and disadvantages of recursive algorithms compared to iterative algorithms.
TASK 1.2
Identify the recursive calls in the following pseudocode algorithm.
FUNCTION Recursive(Num1, Num2 : INTEGER) RETURNS INTEGER
IF Num1 < 0 OR Num2 < 0
THEN

Key focus:

RETURN 1

Recursion

ELSE
IF Num1 < Num2
THEN
Num1

Num1 - 2

RETURN 20 + 2 * Recursive(Num1, Num2)
ELSE
Num2

Num2 - 2

RETURN 10 + 2 * Recursive(Num1, Num2)
ENDIF
ENDIF
ENDFUNCTION
TASK 1.3
Dry run the above algorithm, complete the following trace table and identify the final return value when
the function is called as follows:
Recursive(5, 3)
Function call

Num1

Num2

Final return value
© UCLES 2021

9608/41/PRE/O/N/21

Return value

[Turn over

4
TASK 1.4
Dry run the algorithm when the function is called with Recursive(10, 15).
Create a trace table to show your working.
TASK 1.5
Rewrite the recursive algorithm as an iterative algorithm.

© UCLES 2021

9608/41/PRE/O/N/21

5
TASK 2 – Jackson Structured Programming (JSP)
Study the following JSP structure diagram:

Key focus:

JSP structure diagram

FindValue
Choice

Output

Total =
Total =
Total =
Num1 * Num2 Num2 * Num2 Num1 * Num1

Total

Input
Num1

Num2

TASK 2.1
State the meaning of the circular symbol on the diagram.
TASK 2.2
Write an algorithm using pseudocode to represent the diagram.
TASK 2.3
Draw the JSP structure diagram for the following pseudocode algorithm.
PROCEDURE CalculateResult()
X

0

WHILE X < 10
INPUT X
INPUT Y
ENDWHILE
IF X > Y
THEN
Total

NewTotal(X, Y)

ELSE
Total

NewTotal(Y, X)

ENDIF
OUTPUT Total
ENDPROCEDURE

© UCLES 2021

9608/41/PRE/O/N/21

[Turn over

6
TASK 3 – File processing and exception handling
Helena is writing a computer program to store data about patients in a hospital.
TASK 3.1
Write, using pseudocode, the declaration for a record structure to store the patient’s data.
The record needs to store:
unique number e.g. 15756

Key focus:

Hashing

ward e.g. D1
doctor ID e.g. 15PR
date of admission e.g. 03/04/2021
TASK 3.2
The patient records are stored in a random access file.

A hashing algorithm is applied to the patient’s unique number to generate the location in the file to
store the record.
Write a function that:

•
•
•

takes a patient’s unique number as a parameter
calculates the hash value (using a hashing algorithm of your choice)
returns the location.

TASK 3.3

Key focus:

Write a function that:

•
•
•
•

takes the record to store in the file as a parameter
generates the hash value using the function from TASK 3.2
stores the record in the generated location in the file
returns true if the record was successfully saved and false otherwise.

TASK 3.4
Write a function that is called when the program starts.
The function should:

•
•
•

take as input the patient’s unique number
find the record for that patient’s number in the file
return either the record, if found, or a null record otherwise.

© UCLES 2021

9608/41/PRE/O/N/21

File handling

7
BLANK PAGE

© UCLES 2021

9608/41/PRE/O/N/21

8
BLANK PAGE

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.

© UCLES 2021

9608/41/PRE/O/N/21

Advertisement