Computer Science (9618) · May/June 2023 · Question paper 21

Cambridge Computer Science (9618) question paper for paper 21, May/June 2023 — 9618/21/M/J/23, file 9618_s23_qp_21.pdf.

Advertisement
Loading the paper…
Text of this paper

Cambridge International AS & A Level

* 1 2 8 1 9 6 8 3 4 2 *

COMPUTER SCIENCE
Paper 2 Fundamental Problem-solving and Programming Skills

9618/21
May/June 2023
2 hours

You must answer on the question paper.
You will need:

Insert (enclosed)

INSTRUCTIONS
●
Answer all questions.
●
Use a black or dark blue pen.
●
Write your name, centre number and candidate number in the boxes at the top of the page.
●
Write your answer to each question in the space provided.
●
Do not use an erasable pen or correction fluid.
●
Do not write on any bar codes.
●
You may use an HB pencil for any diagrams, graphs or rough working.
●
Calculators must not be used in this paper.
INFORMATION
●
The total mark for this paper is 75.
●
The number of marks for each question or part question is shown in brackets [ ].
●
No marks will be awarded for using brand names of software packages or hardware.
●
The insert contains all the resources referred to in the questions.

This document has 20 pages. Any blank pages are indicated.
DC (EF/SG) 338525/4
© UCLES 2023

[Turn over

2
Refer to the insert for the list of pseudocode functions and operators.
1

A programmer has written a program which includes the function Calculate().
When the program is run, the function returns an unexpected value.
(a) Describe how a typical Integrated Development Environment (IDE) could be used to help
debug the program to find the errors in the function Calculate().

[4]
(b) The algorithm for function Calculate() contains the three pseudocode statements shown.
Describe the error in each statement or write ‘no error’ if the statement contains no error.
Assume any variables used are of the correct type for the given function.
Statement 1: Index

STR_TO_NUM(("27") + 2)

Error

Statement 2: Index

STR_TO_NUM(MID("CPE1704TKS", 4, 2))

Error

Statement 3: IF MONTH(ThisDate) > '6' THEN
Error

[3]

© UCLES 2023

9618/21/M/J/23

3
(c) The program contains variables with values as follows:
Variable

Value

Active

TRUE

Points

75

Exempt

FALSE

(i)

Complete the table by evaluating each expression.
Expression
1

(Points > 99) OR Active

2

(Points MOD 2 = 0) OR Exempt

3

(Points <= 75) AND (Active OR Exempt)

4

(Active OR NOT Active) AND NOT Exempt

Evaluation

[2]
(ii)

Write expression 4 from the table in part (c)(i) in its simplest form.
[1]

© UCLES 2023

9618/21/M/J/23

[Turn over

4
2

A program contains an algorithm to output a string of a specified length containing identical
characters.
(a) The algorithm is described as follows:
1.
2.
3.
4.

prompt and input a character and store in MyChar

prompt and input an integer and store in MyCount

generate a string consisting of MyChar repeated MyCount times
output the string.

Draw a program flowchart to represent the algorithm.

START

END
[4]
© UCLES 2023

9618/21/M/J/23

5
(b) A different part of the program uses the variable StartDate.
Write pseudocode statements to declare StartDate and assign to it the date corresponding
to 15/11/2005.
Declaration
Assignment
[3]

© UCLES 2023

9618/21/M/J/23

[Turn over

6
3

Customers collect points every time they make a purchase at a store.
A program is used to manage the points system and the table lists some of the information stored
for one customer.
Information

Data type required

Name

String

Number of points collected

Integer

Date of birth
(a) (i)

Date

Identify a suitable structure for storing the information for one customer. Explain the
advantage of using this structure.
Structure
Advantage

[4]

(ii)

Describe a data structure that could be used to store the information for all customers.

[2]

© UCLES 2023

9618/21/M/J/23

7
(b) Customers receive points depending on the amount they spend. The number of points
depends on the band that the amount falls into:
Band

Amount

Points

1

Less than $10

5 per whole dollar ($)

2

Between $10 and $100 inclusive

7 per whole dollar ($)

3

Over $100

10 per whole dollar ($)

For example, if the amount is $99.77, this amount is in band 2 and therefore the number of
points is 7 × 99, which is 693 points.
The algorithm to calculate the points from a given amount is expressed as follows:

•
•

work out the appropriate band
calculate and output the number of points.

Apply the process of stepwise refinement to increase the detail of the algorithm. Structure
your algorithm into a sequence of five steps that could be used to produce pseudocode.
Write the five steps.
1

2

3

4

5

[5]
© UCLES 2023
9618/21/M/J/23
[Turn over

8
4

Function Replace() will:
1.

take three parameters:

•

a string (the original string)

•

a char (the original character)

•

a char (the new character)

2.

form a new string from the original string where all instances of the original character are
replaced by the new character

3.

return the new string.

Write pseudocode for function Replace().

[6]

© UCLES 2023

9618/21/M/J/23

9
5

Several companies are developing websites to market a new type of games console. The company
that is first to create a website that can demonstrate the interactive features of the games console
will have an advantage over the others. The requirements for the website are likely to change as
more information about the features of the console are made available.
One company has decided to develop their website using a program development life cycle based
on the waterfall model.
(a) (i)

Give two reasons why this may not be the most appropriate model to use in this case.
Reason 1

Reason 2

[2]

(ii)

Identify a more appropriate program development life cycle model for this scenario.
[1]

(b) The website has been running in test mode for several weeks.
Identify and describe a final stage of testing that should take place before the website is
made available to all customers.
Stage
Description

[3]

© UCLES 2023

9618/21/M/J/23

[Turn over

10
6

A video-conferencing program supports up to six users. Speech from each user is sampled and
digitised (converted from analogue to digital). Digitised values are stored in array Sample.
The array Sample consists of 6 rows by 128 columns and is of type integer. Each row contains
128 digitised sound samples from one user.
The digitised sound samples from each user are to be processed to produce a single value which
will be stored in a 1D array Result of type integer. This process will be implemented by procedure
Mix().
A procedure Mix() will:

•

calculate the average of each of the 6 sound samples in a column

•

ignore sound sample values of 10 or less

•

store the average value in the corresponding position in Result

•

repeat for each column in array Sample

The diagram uses example values to illustrate the process:

Sample:

Result:

© UCLES 2023

1
2
3
4
5
6

1
20
20
20
20
20
20

2
20
20
20
20
3
4

3
20
30
40
50
5
2

20

20

35

9618/21/M/J/23

...

126 127 128
30 30
2
50 30
3
40 40
4
40 50 20
6
60
4
4
70 30

40

46

25

11
Write pseudocode for procedure Mix().
Assume Sample and Result are global.

[6]

© UCLES 2023

9618/21/M/J/23

[Turn over

12
7

A school has a computerised library system that allows students to borrow books for a fixed length
of time. The system uses text files to store details of students, books and loans.
A new module is to be written which will generate emails to each student who has an overdue
book.
(a) Decomposition will be used to break down the problem of designing the new module into
sub-problems.
Identify three program modules that could be used in the design and describe their use.
Module 1
Use

Module 2
Use

Module 3
Use

[3]

© UCLES 2023

9618/21/M/J/23

13
(b) The program designer produces a structure chart for the new module. Part of the structure
chart is shown:
Module-A()

Module-B()

(i)

Module-C()

Module-D()

Explain the relationship between the four modules shown.

[2]

(ii)

Two new modules are added: Module‑X() and Module‑Y().

•
•
•

Module‑X() has no parameters.
Module‑Y() will take a string and a real number as parameters and return a
Boolean value.
Module‑D() will call either Module‑X() or Module‑Y().

Draw only the part of the structure chart that represents the relationship between
Module‑X(), Module‑Y() and Module‑D().

© UCLES 2023

9618/21/M/J/23

[3]
[Turn over

14
8

A computer shop assembles computers using items bought from several suppliers. A text file
Stock.txt contains information about each item.
Information for each item is stored as a single line in the Stock.txt file in the format:
<ItemNum><SupplierCode><Description>
Item information is as follows:
Format

Comment

ItemNum

4 numeric characters

unique for each item in the range
"0001" to "5999" inclusive

SupplierCode

5 alphabetic characters

to identify the supplier of the item

Description

a string

a minimum of 12 characters

The file is organised in ascending order of ItemNum and does not contain all possible values in
the range.
A programmer has started to define program modules as follows:
Module

Description

SuppExists()
(already written)

•

called with a parameter of type string representing a supplier code

•

returns TRUE if the supplier code is already in use, otherwise returns
FALSE

IsNewSupp()

•

called with a parameter of type string representing a new supplier code

•

returns TRUE if the string only contains alphabetic characters (either
upper or lower case) and the supplier code is not already in use,
otherwise returns FALSE

© UCLES 2023

9618/21/M/J/23

15
(a) Write pseudocode for module IsNewSupp().
Module SuppExists() has already been written and should be used as part of your solution.
Module SuppExists() will generate a run-time error if the given parameter is not
5 characters in length.

[7]

© UCLES 2023

9618/21/M/J/23

[Turn over

16
(b) A new module has been defined:
Module
CheckNewItem()

Description

•

called with a parameter of type string representing a line of
item information

•

checks to see whether an item with the same ItemNum already
exists in the file

•

returns TRUE if the ItemNum is not already in the file, otherwise
returns FALSE

Write efficient pseudocode for module CheckNewItem().

© UCLES 2023

9618/21/M/J/23

17

[7]
(c) The program modules SuppExists(), IsNewSupp() and CheckNewItem() are part of a
group of modules that are combined to create a complete stock control program.
Each module in the program is tested individually during development and is debugged as
necessary. It is then added to the program and further testing performed.
(i)

Identify this method of testing.
[1]

(ii)

One of the modules does not work properly when it is added to the program.
Describe a testing method that can be used to address this problem so that testing can
continue and other modules can be added.

[2]

(d) A new module AddItem() will be used to add information to the Stock.txt file.
State the file mode that should be used for the algorithm within this module.
[1]
(e) A new module FindItem() searches for a given item in the Stock.txt file, which is already
organised in ascending order of ItemNum.
Describe how this organisation may improve the efficiency of the algorithm.

[3]
© UCLES 2023

9618/21/M/J/23

18
BLANK PAGE

© UCLES 2023

9618/21/M/J/23

19
BLANK PAGE

© UCLES 2023

9618/21/M/J/23

20
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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2023

9618/21/M/J/23

Advertisement