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

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

Advertisement
Loading the paper…
Text of this paper

Cambridge International AS & A Level

* 3 1 4 1 1 6 4 8 5 5 *

COMPUTER SCIENCE
Paper 2 Fundamental Problem-solving and Programming Skills

9618/23
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 (PQ/CB) 312089/3
© UCLES 2023

[Turn over

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

The following pseudocode represents part of the algorithm for a program.
Line numbers are for reference only.
10

DECLARE Sheet4 : ARRAY[1:2, 1:50] OF INTEGER

…
100
101
102
103

FOR PCount
0 TO 49
Sheet4[1, PCount]
Sheet4[2, PCount]
NEXT PCount

0
47

(a) The pseudocode contains references to an array.
Complete the table by writing the answer for each row.
Answer
The dimension of the array
The name of the variable used as an array index
The number of elements in the array
[3]
(b) The pseudocode contains two errors. One error is that variable PCount has not been
declared.
Identify the other error and state the line number where it occurs.
Error

Line number
[2]
(c) The pseudocode does not include a declaration for PCount.
State the data type that should be used in the declaration.
[1]

© UCLES 2023

9618/23/M/J/23

3
(d) The pseudocode statements given in the following table are used in other parts of the
algorithm.
Complete the table by placing one or more ticks (✓) in each row.
The first row has already been completed.
Pseudocode statement

Input

INPUT MyChoice

Process

Output

✓

OUTPUT FirstName & LastName
WRITEFILE YourFile, TextLine
READFILE MyFile, TextLine
Result

SQRT(NextNum)
[4]

© UCLES 2023

9618/23/M/J/23

[Turn over

4
2

A program stores a date of birth for a student using a variable, MyDOB, of type DATE.
(a) MyDOB has been assigned a valid value corresponding to Kevin’s date of birth.
Complete the pseudocode statement to test whether Kevin was born on a Thursday.
IF

THEN [2]

(b) A function CheckDate()will take three integer parameters representing a day, month and
year of a given date.
The function will validate the date of birth for a student that the parameters passed to it
represent.
For a date to be valid, a student must be at least 18 in year 2020.
(i)

Two of the parameter values can be checked without reference to the third parameter.
Describe these two checks.
Check 1

Check 2

[2]

(ii)

Several values of the parameter representing the day can only be checked completely
by referring to the value of one other parameter.
Describe this check.

[2]

© UCLES 2023

9618/23/M/J/23

5
BLANK PAGE

© UCLES 2023

9618/23/M/J/23

[Turn over

6
3

A program processes data using a stack. The data is copied to a text file before the program ends.
(a) The following diagram shows the current state of the stack.
The operation of this stack may be summarised as follows:

•
•
•

The TopOfStack pointer points to the last item added to the stack.
The BottomOfStack pointer points to the first item on the stack.
The stack grows upwards when items are added.
Stack
Memory location

Pointer
Value

506

(i)

505

WWW

504

YYY

503

XXX

502

ZZZ

501

NNN

500

PPP

TopOfStack

BottomOfStack

An error will be generated if an attempt is made to POP a value when the stack is empty.
State the maximum number of consecutive POP operations that could be performed on
the stack shown above before an error is generated.
[1]

(ii)

The following operations are performed:
1.
2.
3.
4.
5.
6.

© UCLES 2023

POP and store value in variable Data1
POP and store value in variable Data2
PUSH value AAA
PUSH value BBB
POP and discard value
POP and store value in variable Data2

9618/23/M/J/23

7
Complete the diagram to show the state of the stack and the variables after the given
operations have been performed.
Stack
Memory location

Pointer
Value

506
505
504
503
502

Variable

501

Data1

500

Data2

Value

[4]
(b) The data is copied to a text file before the program ends.
(i)

State an advantage of writing the data from the stack to a text file before the program
ends.

[1]

(ii)

A module SaveStack() will write the data from the stack to a text file.
Express an algorithm for SaveStack() as five steps that could be used to produce
pseudocode.
Write the five steps.
Step 1

Step 2

Step 3

Step 4

Step 5

© UCLES 2023

[5]
9618/23/M/J/23
[Turn over

8
4

A function MakeString() will:
1.
2.
3.

take two parameters:
a count as an integer
a character
generate a string of length equal to the count, made up of the character
return the string generated, or return "ERROR" if the count is less than 1.

•
•

For example, the function call:
MakeString(3, 'Z') will return the string "ZZZ"
Write pseudocode for function MakeString().

[6]

© UCLES 2023

9618/23/M/J/23

9
5

A program is designed, coded and compiled without errors. The compiled code is sent for testing.
(a) The program will be tested using the walkthrough method.
Additional information will be needed before this method can be used.
Identify this additional information and explain why it is needed.
Additional information

Explanation

[3]
(b) Testing is completed and the program is made available to users.
Some time later, changes are made to the program to improve the speed of response.
State the type of maintenance that has been applied to the program.
[1]

© UCLES 2023

9618/23/M/J/23

[Turn over

10
6

A procedure Select() will:
1.
2.

take two integer values as parameters representing start and end values where both values
are greater than 9 and the end value is greater than the start value
output each integer value between the start and the end value (not including the start and
end values), where the sum of the last two digits is 6, for example, 142.

(a) Write pseudocode for procedure Select().
Parameter validation is not required.

[7]
© UCLES 2023

9618/23/M/J/23

11
(b) The check performed by procedure Select() on the last two digits is needed at several
places in the program and will be implemented using a new function.
The new function CheckNum() will:

•
•
•

allow the required sum to be specified (not just 6)
check one number
return an appropriate value.

Describe the function interface and two advantages of this modular approach.
Interface

Advantage 1

Advantage 2

[4]

© UCLES 2023

9618/23/M/J/23

[Turn over

12
7

A school has a library system which allows students to borrow books for a length of time.
Information relating to students and books is stored in text files. Student information includes
name, home address, email address, date of birth, tutor and subject choices. Book information
includes author, title, subject category, library location and the date that the book was borrowed.
A program helps the staff to manage the borrowing of books.
(a) A new module needs to be written to generate emails to send to students who have an
overdue book. Students who are sent an email are prevented from borrowing any more books
until the overdue book is returned.
The process of abstraction has been used when designing the new module.
(i)

State the purpose of applying abstraction to this problem.

[1]

(ii)

Identify one item of information that is required and one item that is not required in the
new module. Justify your choices.
Item required
Justification

Item not required
Justification

[2]

(iii)

Identify two operations that would be required to process data when an overdue book is
returned.
Operation 1

Operation 2

[2]

© UCLES 2023

9618/23/M/J/23

13
(b) Part of the library program contains program modules with headers as follows:
Pseudocode module header
PROCEDURE Module-X()
PROCEDURE Module-Y(BYREF RA : INTEGER, SA : REAL)
PROCEDURE Overlay()
FUNCTION Replace(RA : INTEGER, RB : BOOLEAN) RETURNS BOOLEAN
FUNCTION Reset(TA : STRING) RETURNS INTEGER
Module-X() and Module-Y() are both called from module Overlay().
Complete the structure chart.

[3]

© UCLES 2023

9618/23/M/J/23

[Turn over

14
8

A computer shop assembles desktop 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 number for each item in the range “0001”
to “5999” inclusive

SupplierCode

3 alphabetic characters

code 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.
The programmer has defined the first program module as follows:
Module

Description

ChangeSupp()

• called with two parameters Code1 and Code2 of type string that represent
valid supplier codes

• creates a new file NewStock.txt from the contents of the

file Stock.txt where any reference to Code1 is replaced by Code2

• returns a count of the number of items that have had their supplier code
changed

© UCLES 2023

9618/23/M/J/23

15
(a) Write pseudocode for module ChangeSupp().

[8]

© UCLES 2023

9618/23/M/J/23

[Turn over

16
(b) A new module is required:
Module
Report_1()

Description

• takes a parameter of type string that represents a SupplierCode

• searches the Stock.txt file for each line of item information that
contains the given SupplierCode
• produces a formatted report of items for the given SupplierCode,
for example, for supplier DRG, the output could be:
Report for Supplier: DRG
Item

Description

1234
1273
1350

USB Printer Cable 3 m
32GB USB Flash Drive
Mouse Mat 320 x 240 mm

Number of items listed: 3
Write pseudocode for module Report_1().

© UCLES 2023

9618/23/M/J/23

17

[6]

© UCLES 2023

9618/23/M/J/23

[Turn over

18
(c) The format of the output from module Report_1() from part (b) is changed. The number of
items listed is moved to the top of the report as shown in the example:
Report for Supplier: DRG
Number of items listed: 3

(i)

Item

Description

1234
1273
1350

USB Printer Cable 3 m
32GB USB Flash Drive
Mouse Mat 320 x 240 mm

Explain why this new layout would increase the complexity of the algorithm.

[2]

(ii)

The algorithm will be modified to produce the report in the new format. The modified
algorithm will be implemented so that the file Stock.txt is only read once.
Describe the modified algorithm.

[3]

© UCLES 2023

9618/23/M/J/23

19
BLANK PAGE

© UCLES 2023

9618/23/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/23/M/J/23

Advertisement