0% found this document useful (0 votes)
13 views441 pages

CS 2-24

This document is an insert for the Cambridge International AS & A Level Computer Science Paper 2 exam, which includes essential resources and guidelines for answering questions. It outlines various string, numeric, date, and text file functions, as well as operators and comparison operators relevant to programming. Additionally, it provides a mark scheme for Paper 1, detailing how marks are awarded based on specific content and principles.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views441 pages

CS 2-24

This document is an insert for the Cambridge International AS & A Level Computer Science Paper 2 exam, which includes essential resources and guidelines for answering questions. It outlines various string, numeric, date, and text file functions, as well as operators and comparison operators relevant to programming. Additionally, it provides a mark scheme for Paper 1, detailing how marks are awarded based on specific content and principles.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 441

Cambridge International AS & A Level

COMPUTER SCIENCE 9618/23


Paper 2 Fundamental Problem-solving and Programming Skills May/June 2024

INSERT 2 hours

INFORMATION
*6806807822-I*

● This insert contains all the resources referred to in the questions.


● You may annotate this insert and use the blank spaces for planning. Do not write your answers on the
insert.

This document has 4 pages.

DC (SL) 342707
© UCLES 2024 [Turn over
2

An error will be generated if a function call is not properly formed or if the parameters are of an incorrect
type or an incorrect value.

String and character functions

• A string of length 1 may be considered to be either of type CHAR or STRING


• A CHAR may be assigned to, or concatenated with, a STRING
• A STRING of length greater than 1 cannot be assigned to a CHAR

LEFT(ThisString : STRING, x : INTEGER) RETURNS STRING


returns leftmost x characters from ThisString
Example: LEFT("ABCDEFGH", 3) returns "ABC"
RIGHT(ThisString : STRING, x : INTEGER) RETURNS STRING
returns rightmost x characters from ThisString
Example: RIGHT("ABCDEFGH", 3) returns "FGH"
MID(ThisString : STRING, x : INTEGER, y : INTEGER) RETURNS STRING
returns a string of length y starting at position x from ThisString
Example: MID("ABCDEFGH", 2, 3) returns string "BCD"
LENGTH(ThisString : STRING) RETURNS INTEGER
returns the integer value representing the length of ThisString
Example: LENGTH("Happy Days") returns 10
TO_UPPER(x : <datatype>) RETURNS <datatype>

<datatype> may be CHAR or STRING


returns an object of type <datatype> formed by converting all characters of x to upper case.
Examples:
• TO_UPPER("Error 803") returns "ERROR 803"
• TO_UPPER('a') returns 'A'
TO_LOWER(x : <datatype>) RETURNS <datatype>

<datatype> may be CHAR or STRING


returns an object of type <datatype> formed by converting all characters of x to lower case.
Examples:
• TO_LOWER("JIM 803") returns "jim 803"
• TO_LOWER('W') returns 'w'
NUM_TO_STR(x : <datatype1>) RETURNS <datatype2>
returns a string representation of a numeric value.
<datatype1> may be REAL or INTEGER, <datatype2> may be CHAR or STRING
Example: NUM_TO_STR(87.5) returns "87.5"
If x is a negative value, the returned value will be a string beginning with the '–' character.
STR_TO_NUM(x : <datatype1>) RETURNS <datatype2>
returns a numeric representation of a string.
<datatype1> may be CHAR or STRING, <datatype2> may be REAL or INTEGER
Example: STR_TO_NUM("23.45") returns 23.45
If the string begins with the '–' character, the returned value will be negative.

© UCLES 2024 9618/23/INSERT/M/J/24


3

IS_NUM(ThisString : <datatype>) RETURNS BOOLEAN


returns TRUE if ThisString represents a valid numeric value.
<datatype> may be CHAR or STRING
Example: IS_NUM("-12.36") returns TRUE
ASC(ThisChar : CHAR) RETURNS INTEGER
returns an integer value (the ASCII value) of character ThisChar
Example: ASC('A') returns 65, ASC('B') returns 66
CHR(x : INTEGER) RETURNS CHAR
returns the character whose integer value (the ASCII value) is x
Example: CHR(65) returns 'A', CHR(66) returns 'B'

Numeric functions

INT(x : REAL) RETURNS INTEGER


returns the integer part of x
Example: INT(27.5415) returns 27
RAND(x : INTEGER) RETURNS REAL
returns a real number in the range 0 to x (not inclusive of x).
Example: RAND(87) could return 35.430729

Date functions
Date format is assumed to be DD/MM/YYYY unless otherwise stated.

DAY(ThisDate : DATE) RETURNS INTEGER


returns the day number from ThisDate
Example: DAY(04/10/2003) returns 4
MONTH(ThisDate : DATE) RETURNS INTEGER
returns the month number from ThisDate
Example: MONTH(04/10/2003) returns 10
YEAR(ThisDate : DATE) RETURNS INTEGER
returns the year number from ThisDate
Example: YEAR(04/10/2003) returns 2003
DAYINDEX(ThisDate : DATE) RETURNS INTEGER
returns the day index number from ThisDate where Sunday = 1, Monday = 2 etc.
Example: DAYINDEX(09/05/2023) returns 3
SETDATE(Day, Month, Year : INTEGER) RETURNS DATE
returns a value of type DATE with the value of <Day>/<Month>/<Year>
Example: SETDATE(26, 10, 2003) returns a date corresponding to 26/10/2003
TODAY() RETURNS DATE
returns a value of type DATE corresponding to the current date.

© UCLES 2024 9618/23/INSERT/M/J/24 [Turn over


4

Text file functions

EOF(FileName : STRING) RETURNS BOOLEAN


returns TRUE if there are no more lines to be read from file FileName
will generate an error if the file is not already open in READ mode.

Operators
An error will be generated if an operator is used with a value or values of an incorrect type.

concatenates (joins) two strings.


& Example: "Summer" & " " & "Pudding" evaluates to "Summer Pudding"
may also be used to concatenate a CHAR with a STRING

performs a logical AND on two Boolean values.


AND
Example: TRUE AND FALSE evaluates to FALSE

performs a logical OR on two Boolean values.


OR
Example: TRUE OR FALSE evaluates to TRUE

performs a logical NOT on a Boolean value.


NOT
Example: NOT TRUE evaluates to FALSE

finds the remainder when one number is divided by another.


MOD
Example: 10 MOD 3 evaluates to 1

finds the quotient when one number is divided by another.


DIV
Example 10 DIV 3 evaluates to 3

Comparison operators

used to compare two items of the same type.


=
evaluates to TRUE if the condition is true, otherwise evaluates to FALSE
>
Notes:
<
• may be used to compare types REAL and INTEGER
• may be used to compare types CHAR and STRING
>=
• case sensitive when used to compare types CHAR and/or STRING
• cannot be used to compare two records
<=
Examples:
<>
• "Program" = "program" evaluates to FALSE
• Count = 4 evaluates to TRUE when Count contains the value 4

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


Cambridge International AS & A Level

COMPUTER SCIENCE 9618/11


Paper 1 Theory Fundamentals May/June 2024
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge International will not enter into discussions about these mark schemes.

Cambridge International is publishing the mark schemes for the May/June 2024 series for most
Cambridge IGCSE, Cambridge International A and AS Level and Cambridge Pre-U components, and some
Cambridge O Level components.

This document consists of 8 printed pages.

© Cambridge University Press & Assessment 2024 [Turn over


9618/11 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Generic Marking Principles

These general marking principles must be applied by all examiners when marking candidate answers.
They should be applied alongside the specific content of the mark scheme or generic level
descriptions for a question. Each question paper and mark scheme will also comply with these
marking principles.

GENERIC MARKING PRINCIPLE 1:

Marks must be awarded in line with:

 the specific content of the mark scheme or the generic level descriptors for the question
 the specific skills defined in the mark scheme or in the generic level descriptors for the question
 the standard of response required by a candidate as exemplified by the standardisation scripts.

GENERIC MARKING PRINCIPLE 2:

Marks awarded are always whole marks (not half marks, or other fractions).

GENERIC MARKING PRINCIPLE 3:

Marks must be awarded positively:

 marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit
is given for valid answers which go beyond the scope of the syllabus and mark scheme,
referring to your Team Leader as appropriate
 marks are awarded when candidates clearly demonstrate what they know and can do
 marks are not deducted for errors
 marks are not deducted for omissions
 answers should only be judged on the quality of spelling, punctuation and grammar when these
features are specifically assessed by the question as indicated by the mark scheme. The
meaning, however, should be unambiguous.

GENERIC MARKING PRINCIPLE 4:

Rules must be applied consistently, e.g. in situations where candidates have not followed
instructions or in the application of generic level descriptors.

GENERIC MARKING PRINCIPLE 5:

Marks should be awarded using the full range of marks defined in the mark scheme for the question
(however; the use of the full mark range may be limited according to the quality of the candidate
responses seen).

GENERIC MARKING PRINCIPLE 6:

Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should
not be awarded with grade thresholds or grade descriptors in mind.

© Cambridge University Press & Assessment 2024 Page 2 of 8


9618/11 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

1(a) 1 mark for: 1

(A XOR B) NOR C

1(b) 1 mark for NOT B XOR C 2


1 mark for NOT A and final AND plus NOT

2(a) 1 mark each to max 2: 2

 The doorbell only performs the specific tasks of motion detection/video


recording/doorbell ringing
 The motion sensor and digital camera are built into the doorbell
 The CPU/memory/storage/software are all dedicated to this task only
 Only a dedicated microprocessor is required due to the limited processing
requirements

2(b) No mark for identification of monitoring or control 2


1 mark each to max 2 for justification:

Monitoring:
 The turning on of the digital camera does not affect the input to the
sensor/button
 The transmission of the data/video does not affect the input to the
sensor/button
 The ringing of the doorbell does not affect the input to the button

Control:
 Video doorbell does not only store the values from the motion sensor
 The data is processed, generating a signal to start the digital camera
recording
 Button pressed/motion detected causes a signal to be sent over a
network to the smartphone

2(c)(i) 1 mark each to max 2: 2

 Current reading/data from motion sensor


 Current/recent video
 Instructions being executed
 Start-up/BIOS/boot-up instructions

© Cambridge University Press & Assessment 2024 Page 3 of 8


9618/11 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

2(c)(ii) 1 mark for each row: 4

Statement Answer

The two types of logic gate that can be used to create solid NAND
state devices NOR

The number of transistors contained in each cell 2

The type of gate that can retain electrons without power floating

The type of gate that allows or stops current from passing control
through

2(c)(iii) 1 mark each to max 2: 2

 Captured video is transmitted to buffer


 … video is transmitted from buffer to smartphone
 Store recent data in a buffer for the user to rewind
 … instead of storing everything in secondary storage

 Store readings from motion sensor


 … until the microprocessor can process them
 Store video from digital camera
 … before moving it to secondary storage

2(d) 1 mark each to max 3: 3

 Data transmission to user’s smartphone will take longer


 … because there is more data to transmit

 The secondary storage device will fill faster


 … fewer videos will be able to be stored long-term // videos are
overwritten more often

2(e)(i) 1 mark for: 1

Continuous ordered flow of bits over a communication path

2(e)(ii) 1 mark each to max 2: 2

 Real-time is direct from source whereas on-demand is pre-


recorded/downloaded to view later
 Real-time cannot be re-watched, on-demand can be paused, re-watched
etc.
 Real-time plays continually, on-demand downloads sections/blocks and
cannot play until next section is downloaded

© Cambridge University Press & Assessment 2024 Page 4 of 8


9618/11 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

3(a) 1 mark each to max 2: 2

 The interpreter will stop when an error is found


 ... so the error can be corrected in real-time, and the result of changes
seen immediately

 Only one error is displayed at a time


 … so fewer errors to correct simultaneously and no dependent errors

3(b) 1 mark each to max 3: 3

 Program can be distributed without source code


 ... so it cannot be edited/stolen/plagiarised

 Users do not require the translator to run the program


 … so time is not spent retranslating by user

4(a) 1 mark for each correct answer: 4

Program Code ACC


Number Content

1 LDD 20 4
ADD #2

2 LDX 22 5

3 LDI 25 1
INC ACC
SUB 22

4 LDD 19 25
LDM #5
LDM #25

4(b) 1 mark for each correct answer: 3

Program Code ACC Content


Number

1 AND 31 1001 1010

2 XOR B01001111 1101 0101

3 OR #30 1001 1110

© Cambridge University Press & Assessment 2024 Page 5 of 8


9618/11 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

5(a) 1 mark each: 4

 Identification of server in the bank scenario


 Description e.g. Receives requests, processes the requests
 Identification of client in bank scenario
 Description e.g. Sends request to the server, waits and outputs the
response

5(b) 1 mark for each correctly completed term: 5

 odd or even
 7-bits
 odd
 block
 byte

Computer A and Computer B agree on whether to use odd or even parity.


Computer A divides the data into groups of 7-bits. The number of 1s in each
group is counted. If the agreed parity is odd and the group has an even
number of 1s a parity bit of 1 is appended, otherwise a parity bit of 0 is
appended.

In a parity block check the bytes are grouped together, for example in a grid.
The number of 1s in each column (bit position) is counted. A bit is assigned to
each column to make the column match the parity. These parity bits are
transmitted with the data as a parity byte.

5(c)(i) 1 mark each to max 3: 3

 Compares all incoming and outgoing transmissions


 ... against set criteria/whitelist/blacklist

 Blocks all transmissions that do not meet rules


 Blocks data entering from specific ports
 Blocks unauthorised/unknown internal software transmitting data

5(c)(ii) 1 mark each to max 4: 4

e.g.
 Captures an image of the face
 Uses image recognition
 Trained to identify the features of a face in an image
 … using a large number of images
 Analyse images for facial features
 Uses the probability of a match

© Cambridge University Press & Assessment 2024 Page 6 of 8


9618/11 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

6(a) 1 mark each: 6

 User table with the username as the Primary Key


 … containing at least email address, date of birth / age and rating

 Quiz table with Quiz ID or date or file name as the Primary Key.
 … containing at least the other field(s) not used as the PK

 A joining table with an appropriate name including at least fields for user
identification, quiz identification and score
 … with an appropriate Primary Key
 ... and Foreign Keys matching the Primary Keys of the other two tables

USER(Username, Email, DateOfBirth, Rating)


QUIZ(QuizID, Date, Filename)
USER_QUIZ(Username, QuizID, Score)

6(b) 1 mark each to max 2 for data dictionary and max 2 for logical schema: 4

Data dictionary:
 Data about the data in the database // metadata
 Identifies the characteristics of the data that will be stored
 Appropriate example e.g. field names, table name, validation rules, data
types, primary / foreign keys, relationships etc.

Logical schema:
 Conceptual design
 Platform/database independent overview of the database
 Is used to design the physical structure
 Appropriate example e.g. Design of entities / E-R diagram / views

6(c)(i) 1 mark for each correct clause: 2

 Alter table EVENT


 Adding foreign key as PlayerID referencing correct table

ALTER TABLE EVENT


ADD FOREIGN KEY(PlayerID)REFERENCES PLAYER(PlayerID);

6(c)(ii) 1 mark each: 3

 Selecting PlayerID from EVENT


 Counting EventID
 Grouping by the PlayerID

Example:
SELECT PlayerID, COUNT(EventID)
FROM EVENT
GROUP BY PlayerID;

© Cambridge University Press & Assessment 2024 Page 7 of 8


9618/11 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

7 1 mark each: 3

 Working – carried values clearly indicted


 Correct answer 0001 1000
 Overflow clearly indicated as overflow

Example:

10011110
01100001
+ 00011001
(1) 0 0 0 1 1 0 0 0
1 1 1 1 1 1 1........................(carries)

8(a) 1 mark for each correct row: 5

Statement Bus Star Mesh

all devices connect to one central device 

all devices connect to a central cable 

multiple paths for the packets to travel 

robust against damage because if any line fails,  


the rest of the network retains full functionality

most likely to lose data through collisions 

8(b)(i) 1 mark for: 1

to be visible to and accessible by other devices on the internet

8(b)(ii) 1 mark each: 2

 IPv4 has 4 groups of digits whilst IPv6 has 8 groups


 IPv4 is usually represented in denary whilst IPv6 is usually represented
in hexadecimal
 IPv4 groups are between 0 and 255 whilst IPv6 is between 0 and FFFF
 IPv4 is 32 bits whilst IPv6 is 128 bits

© Cambridge University Press & Assessment 2024 Page 8 of 8


Cambridge International AS & A Level

COMPUTER SCIENCE 9618/12


Paper 1 Theory Fundamentals May/June 2024
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge International will not enter into discussions about these mark schemes.

Cambridge International is publishing the mark schemes for the May/June 2024 series for most
Cambridge IGCSE, Cambridge International A and AS Level and Cambridge Pre-U components, and some
Cambridge O Level components.

This document consists of 11 printed pages.

© Cambridge University Press & Assessment 2024 [Turn over


9618/12 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Generic Marking Principles

These general marking principles must be applied by all examiners when marking candidate answers.
They should be applied alongside the specific content of the mark scheme or generic level
descriptions for a question. Each question paper and mark scheme will also comply with these
marking principles.

GENERIC MARKING PRINCIPLE 1:

Marks must be awarded in line with:

 the specific content of the mark scheme or the generic level descriptors for the question
 the specific skills defined in the mark scheme or in the generic level descriptors for the question
 the standard of response required by a candidate as exemplified by the standardisation scripts.

GENERIC MARKING PRINCIPLE 2:

Marks awarded are always whole marks (not half marks, or other fractions).

GENERIC MARKING PRINCIPLE 3:

Marks must be awarded positively:

 marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit
is given for valid answers which go beyond the scope of the syllabus and mark scheme,
referring to your Team Leader as appropriate
 marks are awarded when candidates clearly demonstrate what they know and can do
 marks are not deducted for errors
 marks are not deducted for omissions
 answers should only be judged on the quality of spelling, punctuation and grammar when these
features are specifically assessed by the question as indicated by the mark scheme. The
meaning, however, should be unambiguous.

GENERIC MARKING PRINCIPLE 4:

Rules must be applied consistently, e.g. in situations where candidates have not followed
instructions or in the application of generic level descriptors.

GENERIC MARKING PRINCIPLE 5:

Marks should be awarded using the full range of marks defined in the mark scheme for the question
(however; the use of the full mark range may be limited according to the quality of the candidate
responses seen).

GENERIC MARKING PRINCIPLE 6:

Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should
not be awarded with grade thresholds or grade descriptors in mind.

© Cambridge University Press & Assessment 2024 Page 2 of 11


9618/12 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

1(a) 1 mark for each correct answer: 4

NAND
 The output is 0 when both inputs are 1, otherwise the output is 1

NOR
 The output is 1 when both inputs are 0, otherwise the output is 0

XOR
 The output is 1 when one of the inputs is 1 and the other input is 0,
otherwise the output is 0

OR
 The output is 0 when both inputs are 0, otherwise the output is 1

1(b) 1 mark for both AND gates with correct inputs 2


1 mark for correct OR and NOT gates with correct inputs and no superfluous
gates:

© Cambridge University Press & Assessment 2024 Page 3 of 11


9618/12 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

2(a) 1 mark for each correctly completed statement: 4

 (LCD) displays/screens/lenses
 gyroscope/accelerometer
 direction/speed
 digital cameras

A headset can have one or two (LCD) displays/screens/lenses that output


the image to the user. The headset has speakers that output surround sound
to give a realistic experience.
The user's head movements are detected using a sensor.
This sensor is a gyroscope/accelerometer. The data is transmitted to a
microprocessor that analyses the data to identify the direction/speed of
movement. Some headsets use digital cameras that record the user's eye
movements for analysis.

2(b) 1 mark each to max 3: 3

 The buffer is used as a temporary store for data going to the headset
 Data is transferred into the buffer by the computer
 Data is retrieved from the buffer by the headset
 When the buffer is empty/full an interrupt is sent to the computer
requesting more data/stopping further data being sent
 When the headset has enough data/needs more data, an interrupt is sent
by the headset to the computer to stop sending data from buffer

2(c) 1 mark each to max 3: 3

 EEPROM allows frequent/multiple read/write/erase operations


 … so the headset can take advantage of new features
 … without fully erasing the contents of the firmware in the headset first //
can erase a particular byte or the whole EEPROM
 … without removing the chip(s)/firmware from the headset
 ... the contents of the firmware in the headset can be changed by the user
without technical expertise
 Cheaper to manufacture so headset will be cheaper to purchase

2(d)(i) 1 mark each: 3

 Image is made of pixels and each pixel has one colour


 Each colour has a unique binary code
 Code for the colour of each pixel is stored in sequence

2(d)(ii) 1 mark each to max 2: 2

 List of objects in the drawing


 A list that stores the command/description/equation required to draw each
object
 Properties of each object e.g. the fill colour, line weight/colour

© Cambridge University Press & Assessment 2024 Page 4 of 11


9618/12 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

2(d)(iii) 1 mark each to max 2: 2

 Dedicated connection to the headset // not sharing bandwidth


 Already fast connection that can transmit the data without slowing
 Video may already be a small file size and does not need further
reduction
 Video is not saved so storage is not an issue in the headset

Question Answer Marks

3(a)(i) 1 mark for security measure 3


1 mark each to max 2 for how the chosen measure works:

 Firewall
 Checks incoming connections
 ... against criteria
 Blocks data from entering specific ports
 Blocks data that does not meet whitelist that meets blacklist

 Proxy server
 Prevents devices accessing the web server directly
 Intercepts any requests
 Forwards the request using its own IP address
 Screens returning data before sending it to the user

3(a)(ii) 1 mark for security measure 3


1 mark each to max 2 for description of the chosen measure:

 Encryption
 Encodes/scrambles data
 ... so if it is intercepted it cannot be understood
 Algorithm/key is required to decode the data

© Cambridge University Press & Assessment 2024 Page 5 of 11


9618/12 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

3(b) 1 mark for characteristic 4


1 mark for description of application to examination software:

Thin-client characteristic Description of use in this software

Data is not stored on the Exam papers are stored on the server and
client computer not on the examiner’s computer // exam
papers are not permanently stored on the
examiners’ computers

Client computer is reliant on Examiners cannot mark if their device


access to server cannot access the server / the server ‘goes
down’

Client computer heavily The marking software will not operate


reliant on network/internet without network/internet access
connection

Client computer requires few Examiners can use devices with low
local resources/memory resources and the marking software will still
function

Client computer performs The marking software transmits requests,


minimal functions/processes the server responds and sends the
response to the user

3(c)(i) 1 mark each to max 2: 2

 Receives packets from internet


 Analyses the destination IP address of each packet
 Forwards the packet towards its destination
 ... using the routing table
 Maintains/updates the routing table
 Finds the most efficient route to the destination

3(c)(ii) 1 mark each to max 2: 2

 The PSTN consists of many different types of communication lines


 … therefore the digital data may need to be converted into a different
form/analogue signal
 Data is transmitted in both directions at the same time // duplex data
transmission
 Using a PSTN the communication passes through different switching
centres/ISPs

© Cambridge University Press & Assessment 2024 Page 6 of 11


9618/12 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

4(a) 1 mark for: 1

1-to-many

4(b) 1 mark each: 3

 Creating table EXAM with opening and closing brackets


 All fields with appropriate data types and commas at end of lines
 ExamID as primary key

Example:
CREATE TABLE EXAM(
ExamID varchar NOT NULL,
Subject varchar,
Level int,
TotalMarks int,
PRIMARY KEY(ExamID)
);

4(c) 1 mark each: 2

 Altering table EXAM_QUESTION


 Linking ExamID to ExamID in EXAM

Example.
ALTER TABLE EXAM_QUESTION
ADD FOREIGN KEY (ExamID) REFERENCES EXAM(ExamID);

4(d) 1 mark each to max 5: 5

 STUDENT table identified with suitable Primary Key

 A linking table between STUDENT and EXAM with suitable Primary Key
and appropriate name
 … that includes the Primary Key of the STUDENT table as a Foreign Key
to join with STUDENT
 ... and includes the Primary Key of the EXAM table as a Foreign Key to
join with EXAM

 A linking table between STUDENT and EXAM_QUESTION with suitable


Primary Key and appropriate name
 … that includes the Primary Key of Table 2 as a Foreign Key to join with
Table 2
 … that stores the ExamQuestionID and the mark for that question

© Cambridge University Press & Assessment 2024 Page 7 of 11


9618/12 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

5(a) 1 mark for each correct answer: 4

Program Code ACC Content


Number

1 LDI 15 11
SUB #1

2 LDD 14 13
ADD 11

3 LDM #11 2
ADD #3
SUB 16

4 LDR #2 14
LDX 14
ADD #2

5(b) 1 mark for each correct answer: 3

Program Code ACC Content


Number

1 XOR 29 0100 1001

2 AND #29 0000 0100

3 OR B11111111 1111 1111

© Cambridge University Press & Assessment 2024 Page 8 of 11


9618/12 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

6 1 mark each to max 4 4

Max 3 marks for each management task:

Memory management: Max 3 marks


 Stores data from all currently running programs concurrently in RAM
 Stops the data from overwriting each other in RAM/primary storage
 Decides which processes should be in main memory
 Makes efficient use of memory

Process management: Max 3 marks


 Allows one process to be paused whilst another process can be actioned
 Decides which process is to be run next
 Switches between processes to allow them to share the use of the
processor
 Identification/description of scheduling

© Cambridge University Press & Assessment 2024 Page 9 of 11


9618/12 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

7(a) 1 mark for: 1

3300 kibibytes

7(b) 1 mark each: 3

 Converting 100 to binary 0110 0100 and 10 to binary 0000 1010


 Subtraction method - converting 10 to – 10 and adding // direct
subtraction …
 … correct answer 0101 1010

Method 1: Converting to -10 and adding:

Binary for +10 is 0000 1010

Binary for –10 is 1111 0110

Binary for 100 is 0110 0100

100 + (-10):

01100100
+1 1 1 1 0 1 1 0
(1) 0 1 0 1 1 0 1 0
Carries: 1 1 0 0 1 0 0 0

Method 2: Direct Subtraction

Borrows:
00011010
01100100
–00001010
01011010

7(c) 1 mark for working: 2

1100 0000 1111 // 2048 + 1024 + 8 + 4 + 2 + 1


// (12 * 162) + 15 // (12 * 16 * 16) + 15 // 3072 + 15

1 mark for correct answer:


3087

© Cambridge University Press & Assessment 2024 Page 10 of 11


9618/12 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

8(a) 1 mark each to max 2: 2

 Creates an executable file


 … so the code can be tested multiple times without having to recompile
 … so repeated testing takes less time

8(b) 1 mark for identification of each feature and 1 mark for matching description: 6

e.g.
For coding:
IDE feature Description

Context-sensitive Gives suggestions for code as the user


prompts types instead of having to write/remember
the code

Auto-correct Corrects spelling mistakes so that user has


fewer errors to correct

For presentation:
IDE feature Description

Pretty-printing Colour code keywords so the user can


identify any errors

Expand/collapse (code) The user can hide code that they are not
blocks currently working on

For debugging:
IDE feature Description

Single stepping Run the code one line at a time // shows


the effect of each line of code

Breakpoints Stop the code running at a set point to


check the flow/variable contents

8(c) 1 mark each to max 2: 2

 Saves programming/testing time as code does not have to be written/re-


written from scratch // code does not have to be tested
 Code is already tested so it is more robust/likely to work
 The programmer does not need to maintain the library // library routines
are updated automatically
 Can perform complex calculations that the programmer may be unable to
do
 Makes code more easily readable

© Cambridge University Press & Assessment 2024 Page 11 of 11


Cambridge International AS & A Level

COMPUTER SCIENCE 9618/13


Paper 1 Theory Fundamentals May/June 2024
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge International will not enter into discussions about these mark schemes.

Cambridge International is publishing the mark schemes for the May/June 2024 series for most
Cambridge IGCSE, Cambridge International A and AS Level and Cambridge Pre-U components, and some
Cambridge O Level components.

This document consists of 9 printed pages.

© Cambridge University Press & Assessment 2024 [Turn over


9618/13 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Generic Marking Principles

These general marking principles must be applied by all examiners when marking candidate answers.
They should be applied alongside the specific content of the mark scheme or generic level
descriptions for a question. Each question paper and mark scheme will also comply with these
marking principles.

GENERIC MARKING PRINCIPLE 1:

Marks must be awarded in line with:

 the specific content of the mark scheme or the generic level descriptors for the question
 the specific skills defined in the mark scheme or in the generic level descriptors for the question
 the standard of response required by a candidate as exemplified by the standardisation scripts.

GENERIC MARKING PRINCIPLE 2:

Marks awarded are always whole marks (not half marks, or other fractions).

GENERIC MARKING PRINCIPLE 3:

Marks must be awarded positively:

 marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit
is given for valid answers which go beyond the scope of the syllabus and mark scheme,
referring to your Team Leader as appropriate
 marks are awarded when candidates clearly demonstrate what they know and can do
 marks are not deducted for errors
 marks are not deducted for omissions
 answers should only be judged on the quality of spelling, punctuation and grammar when these
features are specifically assessed by the question as indicated by the mark scheme. The
meaning, however, should be unambiguous.

GENERIC MARKING PRINCIPLE 4:

Rules must be applied consistently, e.g. in situations where candidates have not followed
instructions or in the application of generic level descriptors.

GENERIC MARKING PRINCIPLE 5:

Marks should be awarded using the full range of marks defined in the mark scheme for the question
(however; the use of the full mark range may be limited according to the quality of the candidate
responses seen).

GENERIC MARKING PRINCIPLE 6:

Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should
not be awarded with grade thresholds or grade descriptors in mind.

© Cambridge University Press & Assessment 2024 Page 2 of 9


9618/13 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

1(a) 1 mark for each correct answer: 4

 binary
 3072
 denary/decimal
 2000

A kibibyte has a binary prefix. Three kibibytes is the same as 3072 bytes.
A megabyte has a decimal/denary prefix. Two terabytes is the same as 2000
gigabytes.

1(b) 1 mark for correct answer: 1


F1

1(c) 1 mark for a correct answer: 1

The answer is too long to be represented in the same number of bits as the
binary numbers being added

1(d)(i) 1 mark for all 3 answers correct: 1

Character set Number of bits

ASCII 7

extended ASCII 8

Unicode 16/32

1(d)(ii) 1 mark each: 2

 Each character has a unique binary code


 The binary code for each character is stored in sequence

Question Answer Marks

2(a) 1 mark for working: 2


 4000 * 3000 * 4

1 mark for correct answer:


 48MB

2(b)(i) 1 mark each to max 3: 3

 The file takes less storage space on the web server than if lossless
compression was used
 The file is faster to upload/download to/from the server than if lossless
compression was used
 The file uses less bandwidth to transmit than if lossless compression was
used
 The file consumes less data allowance than if lossless compression was
used

© Cambridge University Press & Assessment 2024 Page 3 of 9


9618/13 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

2(b)(ii) 1 mark each: 2

 Identifies consecutive repeating pixels of the same colour


 Stores the colour /pattern and the number of times it repeats

2(c) 1 mark each to max 2: 2

 Colour/bit depth
 Image resolution

Question Answer Marks

3(a) 1 mark for each correct answer: 4

Program Code ACC


Number Content

1 LDM #50 50
INC ACC
SUB #1

2 LDI 51 97
ADD 52

3 LDR #2 48
LDX 50
DEC ACC

4 LDD 52 44
SUB 54
INC ACC

3(b) 1 mark for each correct answer: 3

Instruction Instruction ACC Content


Number

1 LSL #2 1111 1100

2 XOR 100 1111 0010

3 AND 103 0011 0111

© Cambridge University Press & Assessment 2024 Page 4 of 9


9618/13 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

4(a) 1 mark for: 1

many to 1 // there are many performances of each show

4(b) 1 mark each for: 4

 Creating table PERFORMANCE with opening and closing brackets


 Setting all four attributes with appropriate data types
 Setting PerformanceID as primary key
 Setting ShowID as foreign key referencing SHOW table

Example:
CREATE TABLE PERFORMANCE(
PerformanceID varchar NOT NULL,
ShowID varchar,
ShowDate Date,
StartTime Time,
PRIMARY KEY(PerformanceID),
FOREIGN KEY(ShowID) REFERENCES SHOW(ShowID)
);

4(c) 1 mark each for: 4

 Selecting COUNT of an attribute in PERFORMANCE table with suitable name


 FROM clause
 Joining tables
 Grouping by the title and selecting the title

Example 1:
SELECT SHOW.Title, Count(PERFORMANCE.PerformanceID)
AS NumberOfShowings
FROM PERFORMANCE, SHOW
WHERE PERFORMANCE.ShowID = SHOW.ShowID
GROUP BY SHOW.Title;

Example 2:
SELECT SHOW.Title, Count(PERFORMANCE.PerformanceID)
AS NumberOfShowings
FROM PERFORMANCE INNER JOIN SHOW
ON PERFORMANCE.ShowID = SHOW.ShowID
GROUP BY SHOW.Title;

© Cambridge University Press & Assessment 2024 Page 5 of 9


9618/13 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

4(d) 1 mark each to max 5: 5

e.g.

 CUSTOMER table identified with suitable Primary Key and appropriate


name
 … and other suitable fields including name and email

 BOOKING TABLE identified with suitable Primary Key and appropriate


name
 … that stores the Primary Key of the CUSTOMER table as a Foreign Key
to join with CUSTOMER table
 … and stores the Primary Key of the PERFORMANCE table as a Foreign
Key to join with PERFORMANCE table

 A linking table between Table 2 and SEAT with suitable Primary Key and
appropriate name
 … that includes the Primary Key of Table 2 as a Foreign Key to join with
Table 2
 … that stores the SeatID.

Question Answer Marks

5(a)(i) 1 mark for: 1

Dedicated/bespoke services/storage on a remote server only available to


company

5(a)(ii) 1 mark each to max 3: 3

e.g.
 Not reliant on a third party
 … gives greater control over security/privacy
 … gives greater control over backup
 Storage can be tailored/scalable to company requirements// an example
e.g. the amount of storage accessible/ facilitating the sharing of files

5(b) 1 mark each: 2

 Sending computer transmits packets directly to switch/router/central


device
 Switch/router/central device checks destination address of packet and
forwards directly to that device

5(c)(i) 1 mark each to max 2: 2

 Jamming signal is transmitted by the sending device


 Transmission is aborted
 The sending device waits a random time before trying to send data
again ...
 ... if further collisions occur the wait time is increased

© Cambridge University Press & Assessment 2024 Page 6 of 9


9618/13 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

5(c)(ii) 1 mark each to max 2: 2

 Random time increased each time so can be infinite waiting


 May be constant jamming signal so nothing ever sends
 Certain nodes cannot be prioritised
 High power consumption
 Only suitable for short distance network // limited distance
 Not scalable // more nodes means exponentially longer waiting times

5(d) 1 mark for: 1

Static means the IP for that device does not change and Private means it can
only be accessed/seen/used within the LAN

Question Answer Marks

6 1 mark for each correct line: 3

© Cambridge University Press & Assessment 2024 Page 7 of 9


9618/13 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

7(a) 1 mark for sensor and matching purpose to max 2: 2

Sensor Purpose of sensor in navigation system

Pressure To detect if a table or other obstacle has been hit // to detect


when food is put on/taken off the tray so it can move on

Infra-red To detect if there is an obstacle in the way // to indicate that it


has reached the desired table

Sound To detect if someone is speaking so that it can use AI to


decipher the speech and whether the robot is required to stop

7(b) 1 mark each to max 3: 3

e.g.
 Voice/speech recognition is used
 ... to identify if someone speaking
 The sound is recorded and analysed
 The audio recordings are compared to a database of words/sound waves
 ... to identify the word that has the highest probability of being said
 Natural language recognition is used
 Words are combined and compared to known sentences
 … programmed action(s) for matching sentence(s) are performed

7(c) 1 mark each to max 2: 2

 Feedback ensures that a system operates within set criteria / constraints


 ... by enabling system output to affect subsequent system input
 ... thus allowing conditions to be automatically adjusted

7(d) 1 mark each to max 4: 4

 Resistive: The space between the conductive layers is removed/the


layers touch and a circuit is completed

 Capacitive: The electrical charge changes where the user pressed

 The point of contact is identified


 ... from the change in electrical field
 The software/microprocessor calculates the coordinates

7(e)(i) 1 mark for: 1

Pre-written code/functions/routines that can be imported/called in another


program

© Cambridge University Press & Assessment 2024 Page 8 of 9


9618/13 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

7(e)(ii) 1 mark each to max 4: 4

 Maintenance not needed to be done by the programmer


 ... because the DLL is separate from program
 The calling program does not need recompilation by the programmer when
a DLL file changes
 ... because the DLL file can be updated independently of the calling
program
 … updates will apply to all programs that use the DLL file

7(f)(i) 1 mark for each correct method and 4


1 mark for corresponding description to max 4:

Method Description

Parity byte An additional bit is added to make the number of 1s in the


byte odd or even to match the parity. If a byte with an odd
number of 1 bits is received when even parity is used, there is
an error.

Parity block Parity is calculated horizontally and vertically. A parity byte is


created from the bits produced by the vertical parity check.
This is sent with the data. The parity is re-checked when
received and the position of an incorrect bit can be
determined.

Checksum A calculation is made from the data and the result transmitted
with the data. The receiver repeats the calculation and
compares the result with the value received. If the two are
different, there is an error.

7(f)(ii) 1 mark each to max 2: 2

 Encodes/scrambles data
 ... so if it is intercepted it cannot be understood
 Algorithm/key is required to decode the data

© Cambridge University Press & Assessment 2024 Page 9 of 9


Cambridge International AS & A Level

COMPUTER SCIENCE 9618/21


Paper 2 Fundamental Problem-solving and Programming Skills May/June 2024
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge International will not enter into discussions about these mark schemes.

Cambridge International is publishing the mark schemes for the May/June 2024 series for most
Cambridge IGCSE, Cambridge International A and AS Level and Cambridge Pre-U components, and some
Cambridge O Level components.

This document consists of 12 printed pages.

© Cambridge University Press & Assessment 2024 [Turn over


9618/21 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Generic Marking Principles

These general marking principles must be applied by all examiners when marking candidate answers.
They should be applied alongside the specific content of the mark scheme or generic level
descriptions for a question. Each question paper and mark scheme will also comply with these
marking principles.

GENERIC MARKING PRINCIPLE 1:

Marks must be awarded in line with:

 the specific content of the mark scheme or the generic level descriptors for the question
 the specific skills defined in the mark scheme or in the generic level descriptors for the question
 the standard of response required by a candidate as exemplified by the standardisation scripts.

GENERIC MARKING PRINCIPLE 2:

Marks awarded are always whole marks (not half marks, or other fractions).

GENERIC MARKING PRINCIPLE 3:

Marks must be awarded positively:

 marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit
is given for valid answers which go beyond the scope of the syllabus and mark scheme,
referring to your Team Leader as appropriate
 marks are awarded when candidates clearly demonstrate what they know and can do
 marks are not deducted for errors
 marks are not deducted for omissions
 answers should only be judged on the quality of spelling, punctuation and grammar when these
features are specifically assessed by the question as indicated by the mark scheme. The
meaning, however, should be unambiguous.

GENERIC MARKING PRINCIPLE 4:

Rules must be applied consistently, e.g. in situations where candidates have not followed
instructions or in the application of generic level descriptors.

GENERIC MARKING PRINCIPLE 5:

Marks should be awarded using the full range of marks defined in the mark scheme for the question
(however; the use of the full mark range may be limited according to the quality of the candidate
responses seen).

GENERIC MARKING PRINCIPLE 6:

Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should
not be awarded with grade thresholds or grade descriptors in mind.

© Cambridge University Press & Assessment 2024 Page 2 of 12


9618/21 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Mark scheme abbreviations

/ separates alternative words / phrases within a marking point


// separates alternative answers within a marking point
underline actual word given must be used by candidate (grammatical variants accepted)
max indicates the maximum number of marks that can be awarded
() the word / phrase in brackets is not required, but sets the context

Note: No marks are awarded for using brand names of software packages or hardware.

© Cambridge University Press & Assessment 2024 Page 3 of 12


9618/21 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

1(a) 4
Assignment statement Data type

A  LEFT(MyName, 1) CHAR / STRING

B  Total * 2 INTEGER / REAL

C  INT(ItemCost) / 3 REAL

D  "Odd OR Even" STRING

One mark per row

1(b) 4
Expression Evaluates to

Tries < 10 AND NOT Sorted TRUE

Tries MOD 4 1

TO_LOWER(MID(ID, 3, 1)) 'a' // "a"

LENGTH(ID & "xx") >= Tries TRUE

One mark per row

1(c)(i) The names do not reflect / indicate the purpose of the variable // the names 1
are not meaningful

1(c)(ii) They make the program more difficult to understand / debug / maintain 1

1(c)(iii) One mark from: 1


 Indentation / use of white space
 Capitalisation of keywords
 Use of comments
 Use of modular programming
 Use of local variables
Note: max 1 mark

© Cambridge University Press & Assessment 2024 Page 4 of 12


9618/21 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

2(a) 5

One mark per outlined region:


1 Initialise both counts
2 Increment Tries every time a pair is input
3 Compare A > B and increment Count if TRUE
4 Test for Count = 10 (10th time A > B) – MUST include Yes / No labels
5 If so output Tries, otherwise loop

2(b) One mark per point: 2

1 A (variable of type) string will be input // by example e.g. “67,72”


2 A special / identified character would need to be used to separate each
numeric value // all numbers are fixed length

© Cambridge University Press & Assessment 2024 Page 5 of 12


9618/21 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

3(a) One mark per point: 3

1 The PS contains a null pointer


2 The PF points to the first element on the free list
3 All the nodes are on the free list

3(b) Max 2 marks for 'Variables': 5

The two variables will be of type Integer

The two variables will be used as pointers / indexes to the


arrays.

The values stored in the two variables will indicate the first
element in each list

The first 1D array will be of type String

The first 1D array will be used to store the values // data items
// User IDs

The second 1D array will be of type Integer

The second 1D array will be used to store the pointers // point


to next item

Mark as follows:

One mark for each of the first three rows


One mark for both Array 1 rows
One mark for both Array 2 rows

© Cambridge University Press & Assessment 2024 Page 6 of 12


9618/21 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

4 Example: 6

FUNCTION Check() RETURNS STRING


DECLARE Odd, Even, Index : INTEGER

Odd  0
Even  0

FOR Index  1 TO 100


IF Index MOD 2 = 0 THEN
Even  Even + Data[Index]
ELSE
Odd  Odd + Data[Index]
ENDIF
NEXT Index

ENDFUNCTION

Mark as follows:
1. Function heading, ending and return type
2. Declare local variables Odd, Even and Index as integers
3. Initialise Odd and Even
4. Loop for 100 iterations // through array
5. Sum Odd and Even element values in a loop
6. Compare Odd and Even after the loop and Return appropriate string

© Cambridge University Press & Assessment 2024 Page 7 of 12


9618/21 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

5(a) 6

One mark per zone.

5(b)(i) OTHERWISE : CALL Error(C) 1

5(b)(ii) After the 'Z' clause in the CASE construct // before the ENDCASE 1

© Cambridge University Press & Assessment 2024 Page 8 of 12


9618/21 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

6(a) FUNCTION IsRA(x1, y1, x2, y2, x3, y3 : INTEGER) RETURNS 6


BOOLEAN
DECLARE Len1, Len2, Len3 : INTEGER

Len1  (x1 - x2) ^ 2 + (y1 - y2) ^ 2


Len2  (x1 - x3) ^ 2 + (y1 - y3) ^ 2
Len3  (x2 - x3) ^ 2 + (y2 - y3) ^ 2

IF (Len1 = Len2 + Len3) OR__


(Len2 = Len1 + Len3) OR__
(Len3 = Len1 + Len2) THEN
RETURN TRUE
ELSE
RETURN FALSE
ENDIF

ENDFUNCTION

Mark as follows:

1 Calculate the square of the length of at least one side


2 Calculation of all three lengths squared correctly
3 One correct comparison of square of three lengths
4 All three comparisons…
5 combined using logical operators / nested IF // completely correct
selection
6 Return result correctly in both cases

6(b) 1 mark for statement of problem: 2

Problem:
 The function will return an incorrect value // the test will fail

1 mark for solution:

Solution:
 Round the calculated values (to a known number of decimal places)
 Define a threshold below which any difference can be ignored

Question Answer Marks

7(a)(i) To make the solution easier to design / implement / solve 1

© Cambridge University Press & Assessment 2024 Page 9 of 12


9618/21 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

7(a)(ii) One mark per item and justification 3

Item: mobile phone number


Justification: to send the text message

Item: name
Justification: to personalise the text message

Item: exercise interest


Justification: to determine whether this member would be interested

7(a)(iii) Examples include: 2

 Add a member to a list of those interested in the new class


 Remove the member from future SMS messages
 Read/process Message
 Identify who from

One mark for each.

Max 2 marks

7(b)(i) 2
Means that Update calls (one of) either Sub-A, Sub-B or Sub-C

One mark for each point:


 reference to selection / decision / if
 naming all four modules correctly

7(b)(ii) PROCEDURE Sub-A (Name : STRING, BYREF P2 : BOOLEAN) 4

FUNCTION Sub-B (P1 : REAL) RETURNS REAL

One mark per underlined part in each case

© Cambridge University Press & Assessment 2024 Page 10 of 12


9618/21 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

8(a) FUNCTION DeleteComment(Line : STRING) RETURNS STRING 8


DECLARE NewLine, TwoChars : STRING
DECLARE Count, TrimTo : INTEGER
CONSTANT Comment = "//"

NewLine  Line
TrimTo  0
Count  1
WHILE Count < LENGTH(Line) AND TrimTo = 0
TwoChars  MID(Line, Count, 2) // extract 2 chars
IF TwoChars = Comment THEN
TrimTo  Count
ENDIF
Count  Count + 1
ENDWHILE

IF TrimTo <> 0 THEN


NewLine  LEFT(Line, TrimTo - 1)
ENDIF

RETURN NewLine

ENDFUNCTION

Mark as follows:

1 Loop to length of Line (parameter) // length of Line -1


2 Terminate loop on first double slash
3 Attempt to extract one/two characters in a loop
4 Check for "//" after attempt at extraction in a loop
5 Record start position of comment // Calculate amount of trim required
6 Attempt to trim Line from start of comment
7 Completely correct trimmed Line from start of comment
8 Return Line after a reasonable overall attempt

© Cambridge University Press & Assessment 2024 Page 11 of 12


9618/21 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

8(b) Example: 7

FUNCTION Stage_1(StudentName : STRING) RETURNS INTEGER

DECLARE OldFile, NewFile, Line : STRING


DECLARE Count : INTEGER

OldFile  StudentName & "_src.txt"


NewFile  StudentName & "_S1.txt"
OPENFILE OldFile FOR READ
OPENFILE NewFile FOR WRITE
Count  0

WHILE NOT EOF(OldFile)


READFILE OldFile, Line
Line  DeleteComment(Line)
IF LENGTH(Line) <> 0 THEN
WRITEFILE NewFile, Line
Count  Count + 1
ENDIF
ENDWHILE

CLOSEFILE OldFile
CLOSEFILE NewFile

RETURN Count
ENDFUNCTION

Mark as follows:

1 Generate filenames condone missing “_”


2 Open both files in correct modes and subsequently close
3 Loop to EOF(OldFile)
4 Read a line from OldFile and execute DeleteComment()in a loop
5 Skip blank lines after DeleteComment()in a loop
6 Write Line to stage 1 file and increment Count
7 Return the number of lines after a reasonable attempt at counting

© Cambridge University Press & Assessment 2024 Page 12 of 12


Cambridge International AS & A Level

COMPUTER SCIENCE 9618/22


Paper 2 Fundamental Problem-solving and Programming Skills May/June 2024
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge International will not enter into discussions about these mark schemes.

Cambridge International is publishing the mark schemes for the May/June 2024 series for most
Cambridge IGCSE, Cambridge International A and AS Level and Cambridge Pre-U components, and some
Cambridge O Level components.

This document consists of 12 printed pages.

© Cambridge University Press & Assessment 2024 [Turn over


9618/22 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Generic Marking Principles

These general marking principles must be applied by all examiners when marking candidate answers.
They should be applied alongside the specific content of the mark scheme or generic level
descriptions for a question. Each question paper and mark scheme will also comply with these
marking principles.

GENERIC MARKING PRINCIPLE 1:

Marks must be awarded in line with:

 the specific content of the mark scheme or the generic level descriptors for the question
 the specific skills defined in the mark scheme or in the generic level descriptors for the question
 the standard of response required by a candidate as exemplified by the standardisation scripts.

GENERIC MARKING PRINCIPLE 2:

Marks awarded are always whole marks (not half marks, or other fractions).

GENERIC MARKING PRINCIPLE 3:

Marks must be awarded positively:

 marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit
is given for valid answers which go beyond the scope of the syllabus and mark scheme,
referring to your Team Leader as appropriate
 marks are awarded when candidates clearly demonstrate what they know and can do
 marks are not deducted for errors
 marks are not deducted for omissions
 answers should only be judged on the quality of spelling, punctuation and grammar when these
features are specifically assessed by the question as indicated by the mark scheme. The
meaning, however, should be unambiguous.

GENERIC MARKING PRINCIPLE 4:

Rules must be applied consistently, e.g. in situations where candidates have not followed
instructions or in the application of generic level descriptors.

GENERIC MARKING PRINCIPLE 5:

Marks should be awarded using the full range of marks defined in the mark scheme for the question
(however; the use of the full mark range may be limited according to the quality of the candidate
responses seen).

GENERIC MARKING PRINCIPLE 6:

Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should
not be awarded with grade thresholds or grade descriptors in mind.

© Cambridge University Press & Assessment 2024 Page 2 of 12


9618/22 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Mark scheme abbreviations

/ separates alternative words / phrases within a marking point


// separates alternative answers within a marking point
underline actual word given must be used by candidate (grammatical variants accepted)
max indicates the maximum number of marks that can be awarded
() the word / phrase in brackets is not required, but sets the context

Note: No marks are awarded for using brand names of software packages or hardware.

© Cambridge University Press & Assessment 2024 Page 3 of 12


9618/22 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

1(a) 4
Pseudocode example Selection Iteration Input/Output
FOR Index  1 TO 10
Data[Index]  0 
NEXT Index

WRITEFILE ThisFile,

"****"

UNTIL Level > 25 

IF Mark > 74 THEN


READFILE OldFile,
 
Data
ENDIF

One mark per row.

1(b) 4
Expression

MyInt  INT (3.1415926)

MyChar  MID ("Elwood", 3, 1)

Any of:

 MyString  NUM_TO_STR (INT (27.509))

 MyString  CHR (INT (27.509))

 MyString  TO_UPPER( NUM_TO_STR( 27.509))

 MyString  TO_LOWER( NUM_TO_STR( 27.509))

Any of:

 MyInt  STR_TO_NUM ( RIGHT ("ABC123", 3))


 MyInt  LENGTH ( RIGHT ("ABC123", 3))
 MyInt  LENGTH ( LEFT ("ABC123", 3))

One mark per row

1(c) 1 mark for stating a suitable way of documenting: 2


 Identifier table
1 mark for giving one piece of information that should be recorded.
examples include:
Explanation of what (each) variable is used for
The purpose of (each) variable
An example of data values stored // Initialisation value

© Cambridge University Press & Assessment 2024 Page 4 of 12


9618/22 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

2(a) 5

Mark points
1 Condition for selecting one of the input numbers as largest value
2 … and assign to Ans
3 Condition for selecting largest number for all three number input and
assigning to Ans
4 Average calculated using Num1, Num2 and Num3 and stored in a variable.
Reject use of DIV
5 Output of Ans and average in output symbol / parallelogram

© Cambridge University Press & Assessment 2024 Page 5 of 12


9618/22 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

2(b) Example solutions: 5

Flag  GetStat()
WHILE Flag <> TRUE
FOR Port  1 TO 3
CALL Reset(Port)
NEXT Port
Flag  GetStat()
ENDWHILE

Alternative:

REPEAT
Flag  GetStat()
IF Flag <> TRUE THEN
FOR Port  1 TO 3
CALL Reset(Port)
NEXT Port
ENDIF
UNTIL Flag = TRUE

One mark per point:


1 (Outer) conditional loop testing Flag
2 Correct assignment of Flag from GetStat() in a loop
3 (Inner) loop checking / counting port // Check if Port is different to 4
4 … loop for 3 iterations
5 a call to Reset()in a loop

Question Answer Marks

3(a)(i) Pseudocode: 4

TYPE Component
DECLARE Item_Num : INTEGER
DECLARE Reject : BOOLEAN
DECLARE Stage : CHAR
DECLARE Limit_1 : REAL
DECLARE Limit_2 : REAL
ENDTYPE

Mark as follows:

1 One mark for TYPE and ENDTYPE statements


2 One mark for Item_Num and Reject fields
3 One mark for Stage field
4 One mark for Limit fields as REAL

© Cambridge University Press & Assessment 2024 Page 6 of 12


9618/22 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

3(a)(ii) DECLARE Item : ARRAY [1:2000] OF Component// 2


DECLARE Item : ARRAY [2000] OF Component//
DECLARE Item : ARRAY [0:1999] OF Component

One mark per underlined phrase

3(b) One mark per point: 3

1 Allows for iteration / can use a loop to access the records / data items
2 Use of index to directly access a record in the array // Example of
simplification of code e.g. use of dot notation Item[1].Stage
3 Simplifies the code / algorithm // Reduces duplication of code // Program
easier to write / understand / maintain / test / debug // Data items/record
easier to search / sort / manipulate

Question Answer Marks

4 Example solution: 5

PROCEDURE IsRA()
DECLARE a, b, c : INTEGER

OUTPUT "Input length of the first side"


INPUT a
OUTPUT "Input length of the second side"
INPUT b
OUTPUT "Input length of the third side"
INPUT c

IF (a * a = (b * b) + (c * c)) OR__
(b * b = (a * a) + (c * c)) OR__
(c * c = (a * a) + (b * b)) THEN
OUTPUT "It is right-angled"
ELSE
OUTPUT "Not right-angled"
ENDIF

ENDPROCEDURE

Mark as follows:

1. Procedure heading and ending and declaration of all variables used


2. Appropriate prompt and input for each length
3. One correct length test
4. All three length tests // selection of which test is required
5. Output one of two messages following a reasonable attempt at MP3

© Cambridge University Press & Assessment 2024 Page 7 of 12


9618/22 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

5(a)(i) One mark per error: 3

Syntax:
1. NEXT Index (should be ENDWHILE)
2. '&' used to concatenate an integer (in OUTPUT statement)

Other:
3. Accesses element outside range // Accesses element 0

5(a)(ii) One mark per point: 2

Statement:
 The OTHERWISE statement

Explanation:
 The result of MOD 2 can only be 0 or 1

5(b) Run-time 1

© Cambridge University Press & Assessment 2024 Page 8 of 12


9618/22 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

6(a) Example solution: 7

Function Trim(Name : STRING) RETURNS STRING


CONSTANT Dots = "..."
CONSTANT Space = " "

IF LENGTH(Name) <= 16 THEN


RETURN Name
ENDIF

// Otherwise it has to be trimmed

WHILE LENGTH(Name) > 13


REPEAT
Name  LEFT(Name, LENGTH(Name) - 1) // strip
last char
UNTIL RIGHT(Name, 1) = Space // back to SPACE
ENDWHILE

Name  LEFT(Name, LENGTH(Name) - 1) // remove the


space
Name  Name & Dots
RETURN Name

ENDFUNCTION

Mark as follows:
1. Function heading, ending, parameter and return type
2. If length of original string <= 16 then return original string
3. Any Conditional loop...
4. until string is short enough
5. Inner conditional loop / second condition to identify word(s) to
remove from the end of string // Check to identify word(s) to remove
from the end of string
6. Attempt to strip characters back to space
7. Correct removal of word/words from end of string and remove final
space
8. Concatenate Dots and return result

Max 7 marks

6(b)(i) A (very) large file is created // redundant zeroes are stored in the file 1

6(b)(ii) One mark for: 1


 Values are delimited by a special character / a separator character
 First character indicates sample length

Max 1 mark

6(b)(iii) The algorithm to store / extract / separate the individual values is more 1
complex / takes longer to execute / run / process

NE Algorithm is more complicated

© Cambridge University Press & Assessment 2024 Page 9 of 12


9618/22 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

7(a) Examples include: 3

Module: IdentifyMember()
Use: Identifies a club member who has expressed an interest in a given class

Module: GetMemberPhoneNumber()
Use: Gets the mobile phone number of a member

Module: CreateMessage()
Use: Generates a text message to a member

Module: SendMessage()
Use: Sends a text message to a member in the waiting list

One mark for name and use

Note: max 3 marks

7(b)(i) 5
Input Output Next state

S1

Input-A none S3

Input-A Output-W S3

Input-B none S2

Input-B none S5

Input-A none S2

Input-A Output-X S4

One mark per row 3 to 7

7(b)(ii) Input-B, Input-A 1

Question Answer Marks

8(a) One mark for reason, one for benefit 2

Reason: (Program is) easier to design / implement / test / debug / modify

Benefit: Easier to check that each stage works as expected

© Cambridge University Press & Assessment 2024 Page 10 of 12


9618/22 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

8(b) Example algorithm based on finding position of first non-space character and 6
then using substring function:

FUNCTION DeleteSpaces(Line : STRING) RETURNS STRING


DECLARE NewLine : STRING
DECLARE EndOfLeading : BOOLEAN
DECLARE Count, NumSpaces : INTEGER
DECLARE NextChar : CHAR
CONSTANT Space = " "

NumSpaces  0
EndOfLeading  FALSE

FOR Count  1 TO LENGTH(Line)


NextChar  MID(Line, Count, 1)
IF NextChar <> Space AND EndOfLeading = FALSE
THEN
NumSpaces  Count - 1 // the number to trim
EndOfLeading = TRUE
ENDIF
NEXT Count

NewLine  RIGHT(Line, LENGTH(Line) - NumSpaces)

RETURN NewLine
ENDFUNCTION

Mark as follows:

1 Loop to length of parameter // Loop until first non-space


character in Line
2 Extract a character in a loop
3 Identify first non-space character in a loop
4 Attempt at removing leading spaces in Line
5 Leading spaces removed from Line / / Create new string without leading
space
6 Return a string following a reasonable attempt at removing leading spaces
in Line

© Cambridge University Press & Assessment 2024 Page 11 of 12


9618/22 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

8(c) Example: 8

PROCEDURE Stage_2(F1, F2 : STRING)

DECLARE Line : STRING


DECLARE Count : INTEGER

Count  0

OPEN F1 FOR READ


OPEN F2 FOR APPEND

WHILE NOT EOF(F1)


READFILE F1, Line
Line  DeleteSpaces(Line)
Line  DeleteComment(Line)
IF Line <> "" THEN
WRITEFILE F2, Line // skip blank lines
ELSE
Count  Count + 1
ENDIF
ENDWHILE

CLOSEFILE F1
CLOSEFILE F2

OUTPUT Count, " blank lines were removed"

ENDPROCEDURE

Mark as follows:

1 Procedure heading, parameters, ending


2 Open both files in correct modes and subsequently close
3 Loop to EOF(F1)
4 Read a line from F1 in a loop
5 Assign return values from DeleteComment() and DeleteSpaces()
in a loop
6 Check return value following both MP5 function calls is not an empty
string and if so write to F2 in a loop
7 Count the blank lines in a loop
8 Output number of blank lines removed following a reasonable attempt
after the loop

© Cambridge University Press & Assessment 2024 Page 12 of 12


Cambridge International AS & A Level

COMPUTER SCIENCE 9618/23


Paper 2 Fundamental Problem-solving and Programming Skills May/June 2024
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge International will not enter into discussions about these mark schemes.

Cambridge International is publishing the mark schemes for the May/June 2024 series for most
Cambridge IGCSE, Cambridge International A and AS Level and Cambridge Pre-U components, and some
Cambridge O Level components.

This document consists of 13 printed pages.

© Cambridge University Press & Assessment 2024 [Turn over


9618/23 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Generic Marking Principles

These general marking principles must be applied by all examiners when marking candidate answers.
They should be applied alongside the specific content of the mark scheme or generic level
descriptions for a question. Each question paper and mark scheme will also comply with these
marking principles.

GENERIC MARKING PRINCIPLE 1:

Marks must be awarded in line with:

 the specific content of the mark scheme or the generic level descriptors for the question
 the specific skills defined in the mark scheme or in the generic level descriptors for the question
 the standard of response required by a candidate as exemplified by the standardisation scripts.

GENERIC MARKING PRINCIPLE 2:

Marks awarded are always whole marks (not half marks, or other fractions).

GENERIC MARKING PRINCIPLE 3:

Marks must be awarded positively:

 marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit
is given for valid answers which go beyond the scope of the syllabus and mark scheme,
referring to your Team Leader as appropriate
 marks are awarded when candidates clearly demonstrate what they know and can do
 marks are not deducted for errors
 marks are not deducted for omissions
 answers should only be judged on the quality of spelling, punctuation and grammar when these
features are specifically assessed by the question as indicated by the mark scheme. The
meaning, however, should be unambiguous.

GENERIC MARKING PRINCIPLE 4:

Rules must be applied consistently, e.g. in situations where candidates have not followed
instructions or in the application of generic level descriptors.

GENERIC MARKING PRINCIPLE 5:

Marks should be awarded using the full range of marks defined in the mark scheme for the question
(however; the use of the full mark range may be limited according to the quality of the candidate
responses seen).

GENERIC MARKING PRINCIPLE 6:

Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should
not be awarded with grade thresholds or grade descriptors in mind.

© Cambridge University Press & Assessment 2024 Page 2 of 13


9618/23 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Mark scheme abbreviations

/ separates alternative words / phrases within a marking point


// separates alternative answers within a marking point
underline actual word given must be used by candidate (grammatical variants accepted)
max indicates the maximum number of marks that can be awarded
() the word / phrase in brackets is not required, but sets the context

Note: No marks are awarded for using brand names of software packages or hardware.

© Cambridge University Press & Assessment 2024 Page 3 of 13


9618/23 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

1(a)(i) Two marks for the benefits: 2


1. The code can be called when needed
2. Any subsequent change to the algorithm / calculation needs to be made
once only // Easier to manage / maintain (the program)
3. Less code / no code duplication
4. The algorithm / code / calculation can be designed / coded / tested once

Note: Max 2 marks

1(a)(ii) One mark per point: 3


1. Create a module / function / procedure / subroutine using the (old) code /
algorithm
2. Replace the old code / algorithm wherever it appears with a call to the
module / function / procedure / subroutine
3. Pass the data as parameter(s) // Use of global variable(s)
4. Return the result (of the calculation) // Assign result to global variable(s) /
BYREF parameter(s)
5. Create local variables as needed (to perform the calculation)

Note: Max 3 marks

1(b) 4
Pseudocode expression Evaluates to

MID("Random", 2, 3) "and"

5 + DAY(10/11/2023) 15

IS_NUM("45000") TRUE

(20 MOD 3) + 1 3

One mark per row

Question Answer Marks

2(a) One mark per point: 5

1. Open the file (in read mode and subsequently close)


2. Initialise an index variable (to 1 // 0)
3. Repeat (the next three steps) until the end of file is reached
4. Read a line from the file (into a string variable)
5. Store the line / variable in the array at the index
6. Increment the index in a loop

Note: max 5 marks

© Cambridge University Press & Assessment 2024 Page 4 of 13


9618/23 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

2(b) One mark per point: 2

Construct: a conditional loop

Use: To keep repeating until the end of the file is reached

ALTERNATIVE:

Construct: a selection statement

Use: To test / check the value returned by the EOF() function

Question Answer Marks

3(a)(i) Example solution using AND 3

IF Batch[ThisIndex].Weight >= Min AND


Batch[ThisIndex].Weight <= Max THEN

Alternative solution using OR

IF Batch[ThisIndex].Weight < Min OR


Batch[ThisIndex].Weight > Max THEN

Mark as follows:
1. Reference to Batch[ThisIndex].Weight
2. A valid check for one boundary
3. A valid check for other boundary with correct logic operator

3(a)(ii) One mark for either: 1

 Set the Item_ID field to an empty string / NULL / invalid value


 Set Weight to <= 0 / zero

© Cambridge University Press & Assessment 2024 Page 5 of 13


9618/23 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

3(b) 5

Zone 1

Zone 2

Zone 3

Zone 4

Zone 5

One mark per zone

© Cambridge University Press & Assessment 2024 Page 6 of 13


9618/23 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

4(a) Example solution: 6

PROCEDURE TwoParts()
DECLARE NextNum, Average : REAL

TotalA  0.0 // 0
TotalB  0.0 // 0

REPEAT
INPUT NextNum
TotalA  TotalA + NextNum
UNTIL NextNum = 0

REPEAT
INPUT NextNum
TotalB  TotalB + NextNum
UNTIL NextNum = 0

Average  (TotalA + TotalB) / 2


OUTPUT "The average is ", Average
ENDPROCEDURE

Mark as follows:
1. Procedure heading and ending
2. Declare all local variables
3. Initialise TotalA and TotalB
4. First conditional loop until zero entered, summing TotalA // Loop until
both parts (sequences) have been entered
5. Second conditional loop until zero entered, summing TotalB // Loop
summing appropriate Totals
6. Calculation of average and output with a message // Calculation of the
average for the values making up the two totals and both output with a
suitable message

4(b)(i) (1D) array of 20 reals 2

Marks as follows:
1 mark for array
1 mark for 20 reals

4(b)(ii) One mark per point: 3

1 (Multiple instances referenced via a single identifier so) fewer identifiers


needed
2 Easier to process / search / organise / access the data // Values may be
accessed via a loop-controlled variable /an index //An array / data can be
iterated through
3 Makes the program/algorithm easier to write / design / understand /
maintain / modify // Simplifies the program // Easier to debug / test

© Cambridge University Press & Assessment 2024 Page 7 of 13


9618/23 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

5(a) One mark per point 2

 Count-controlled loop
 the number of iterations is known

5(b) Two mark for Statement of Problem: 4

1 The functions will return the same value every time they are called
2 ... because Label / the parameter value does not change within the loop

Two marks for Solution:

3 Assign FormatA(Label) and FormatB(Label) to two (local) variables


before the loop
4 Use the (new) variables in place of the function calls / in the loop //
Replace the references to FormatA() and FormatB() in the CASE
clauses with the new variable names

© Cambridge University Press & Assessment 2024 Page 8 of 13


9618/23 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

6(a) Example Solutions: 6

PROCEDURE Progress(Percent : INTEGER, Root : STRING)


DECLARE StepValue : INTEGER
DECLARE Filename : STRING

StepValue  (Percent DIV 10) + 1 // INT(Percent / 10)


+ 1
FileName  Root & "-" & NUM_TO_STR(StepValue) &
".bmp"
CALL Display(Filename)
ENDPROCEDURE

Alternative:

PROCEDURE Progress(Percent : INTEGER, Root : STRING)


DECLARE StepValue : INTEGER
DECLARE Filename : STRING
DECLARE Found : BOOLEAN
StepValue  1
Found  FALSE
REPEAT
IF Percent < StepValue * 10 THEN
Found  TRUE
ENDIF
StepValue  StepValue + 1
UNTIL Found
Filename  Root & "-" & NUM_TO_STR(StepValue - 1) &
".bmp"
CALL Display(Filename)
ENDPROCEDURE

Mark as follows for use of DIV/INT or loop solution:


1 Procedure heading, parameters and ending
2 Calculate StepValue as integer value // Attempt at calculating file
number
3 Add 1 to obtain file number // Completely correct file number calculation
4 Use of NUM_TO_STR() to convert file number to string and use
5 Concatenate Root, hyphen, file number and ".bmp" suffix
6 Call Display() with filename as parameter following a reasonable
attempt

© Cambridge University Press & Assessment 2024 Page 9 of 13


9618/23 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

6(a) Example Selection Solution:

PROCEDURE Progress(Percent : INTEGER, Root : STRING)


DECLARE Filename, StepValue : STRING
CASE OF Percent
< 10 : StepValue  "1"
< 20 : StepValue  "2"
< 30 : StepValue  "3"
< 40 : StepValue  "4"
< 50 : StepValue  "5"
< 60 : StepValue  "6"
< 70 : StepValue  "7"
< 80 : StepValue  "8"
< 90 : StepValue  "9"
< 100 : StepValue  "10"
OTHERWISE : StepValue  "11"
ENDCASE
Filename  Root & "-" & StepValue & ".bmp"
CALL Display(Filename)
ENDPROCEDURE

Mark as follows for loop solution:


1 Procedure heading, parameters and ending
2 Correct selection construct(s) structure
3 Use of selection statement to obtain two file numbers
4 Use of selection statement to obtain all the file numbers
5 Concatenate Root, hyphen, file number and ".bmp" suffix
6 Call Display() once with filename as parameter following a reasonable
attempt

6(b)(i) Example answer: 2

FUNCTION Progress2(Percent, Steps : INTEGER, Root :


STRING) RETURNS STRING

One mark for each:


 Keyword FUNCTION Progress2 and three parameters of correct type
 Keyword RETURNS and type string

6(b)(ii) The progress display will more accurately show the progress of the task 1

© Cambridge University Press & Assessment 2024 Page 10 of 13


9618/23 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

7(a)(i) Mod-B() and Mod-E() 1

7(a)(ii) Points required: 2


1 any change made to the parameter value / Par3 within Mod-G()is
reflected in the (subsequent) value in the calling module / Mod-C() (after
Mod-G() terminates)
2 any change made to the parameter value / Par3 within Mod-F()is NOT
reflected in the (subsequent) value in the calling module / Mod-C() (after
Mod-F() terminates)

Mark as follows:
1 mark for a reasonable attempt to explain
2 marks for full explanation including context

7(b) 6

One mark per bullet:


1 All modules correctly labelled and interconnected
2 Parameters between Mod-A and Mod-B and return value from Mod-B
3 Parameters between Mod-A and Mod-C
4 Diamond applied to Mod-B only
5 Iteration arrow applied to Mod-C only
6 All parameters at lower level and return value

© Cambridge University Press & Assessment 2024 Page 11 of 13


9618/23 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

8(a) Example: 7

FUNCTION Header(Line : STRING) RETURNS STRING

IF LENGTH(Line) >= 13 THEN


IF TO_UPPER(LEFT(Line, 9)) = "FUNCTION " THEN
RETURN "F" & RIGHT(Line, LENGTH(Line) - 9)
ENDIF

IF TO_UPPER(LEFT(Line, 10)) = "PROCEDURE " THEN


RETURN "P" & RIGHT(Line, LENGTH(Line) - 10)
ENDIF
ENDIF

RETURN ""

ENDFUNCTION

Mark as follows:

1 Function heading, parameter, return type and ending


2 Check that the line is at least 13 characters long before attempting to
extract and return empty string
3 Attempt at: Extract characters, 9 or 10 characters, corresponding to
keyword plus space and compare with appropriate keyword plus space
4 Completely correct MP3
5 Use of type case conversion to allow for 'any case'
6 Calculation of 'rest of line' and concatenation with 'P or 'F'
7 Return string

© Cambridge University Press & Assessment 2024 Page 12 of 13


9618/23 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED

Question Answer Marks

8(b) Example: 8

PROCEDURE FindModules(FileName : STRING)


DECLARE Line : STRING
DECLARE Index, LineNum : INTEGER

OPENFILE FileName FOR READ

Index  1
LineNum  0

WHILE NOT EOF(FileName)


READFILE FileName, Line
LineNum  LineNum + 1
Line  Header(Line)
IF Line <> "" THEN
ModInfo[Index, 1]  NUM_TO_STR(LineNum)
ModInfo[Index, 2]  LEFT(Line, 1)
ModInfo[Index, 3]  RIGHT(Line, LENGTH(Line) -
1)
Index  Index + 1
ENDIF
ENDWHILE

CLOSEFILE FileName

ENDPROCEDURE

Mark as follows:

1 Open file in READ mode and subsequently close


2 Loop to EOF(FileName)
3 Read a line from the file and maintain LineNum in a loop
4 Call Header() and use return value in a loop
5 Test return value for "" in a loop
6 Attempt at all three-array assignment for all columns in correct row
7 Correct values assigned to all columns of array
8 Maintain correct array row index

© Cambridge University Press & Assessment 2024 Page 13 of 13


Cambridge International AS & A Level

COMPUTER SCIENCE 9618/31


Paper 3 Advanced Theory May/June 2024
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge International will not enter into discussions about these mark schemes.

Cambridge International is publishing the mark schemes for the May/June 2024 series for most
Cambridge IGCSE, Cambridge International A and AS Level and Cambridge Pre-U components, and some
Cambridge O Level components.

This document consists of 14 printed pages.

© Cambridge University Press & Assessment 2024 [Turn over


9618/31 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Generic Marking Principles

These general marking principles must be applied by all examiners when marking candidate answers. They should be applied alongside the
specific content of the mark scheme or generic level descriptions for a question. Each question paper and mark scheme will also comply with these
marking principles.

GENERIC MARKING PRINCIPLE 1:

Marks must be awarded in line with:

 the specific content of the mark scheme or the generic level descriptors for the question
 the specific skills defined in the mark scheme or in the generic level descriptors for the question
 the standard of response required by a candidate as exemplified by the standardisation scripts.

GENERIC MARKING PRINCIPLE 2:

Marks awarded are always whole marks (not half marks, or other fractions).

GENERIC MARKING PRINCIPLE 3:

Marks must be awarded positively:

 marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit is given for valid answers which go beyond
the scope of the syllabus and mark scheme, referring to your Team Leader as appropriate
 marks are awarded when candidates clearly demonstrate what they know and can do
 marks are not deducted for errors
 marks are not deducted for omissions
 answers should only be judged on the quality of spelling, punctuation and grammar when these features are specifically assessed by the
question as indicated by the mark scheme. The meaning, however, should be unambiguous.

GENERIC MARKING PRINCIPLE 4:

Rules must be applied consistently, e.g. in situations where candidates have not followed instructions or in the application of generic level
descriptors.

© Cambridge University Press & Assessment 2024 Page 2 of 14


9618/31 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
GENERIC MARKING PRINCIPLE 5:

Marks should be awarded using the full range of marks defined in the mark scheme for the question (however; the use of the full mark range may
be limited according to the quality of the candidate responses seen).

GENERIC MARKING PRINCIPLE 6:

Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should not be awarded with grade thresholds or
grade descriptors in mind.

© Cambridge University Press & Assessment 2024 Page 3 of 14


9618/31 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(a) One mark per mark point (Max 3) 3


MP1 conversion of exponent 001001 to 9
MP2 application of exponent to mantissa to go from 0.100111100 to 100111100 // 256 + 32 + 16 + 8 + 4 seen // 64/128
+ 8/128 + 4/128 + 2/128 + 1/128 = 79/128 // 1/2 + 1/16 + 1/32 + 1/64 + 1/128 = 79/128
MP3 correct answer = 316

1(b) One mark per mark point (Max 3) 3


MP1 number converted to binary 10011001.01 // number converted to positive 102.75, reversed bits and 1 added.
(0)1100110.11  10011001.00  10011001.01 // -128 + 16 + 8 + 1 + 0.25 = –102.75
MP2 exponent = 7 // Moving binary point the correct number of places
MP3 correct answer

Mantissa Exponent
1 0 0 1 1 0 0 1 0 1 0 0 0 1 1 1

© Cambridge University Press & Assessment 2024 Page 4 of 14


9618/31 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a) Two marks for all protocols in correct position 2


One mark for at least two protocols in correct position

Application

Transport

Internet

Link

2(b) One mark per mark point (Max 2) 2


MP1 The transport layer is responsible for delivery of data from the source host to the destination host
MP2 It is where data is broken up into packets and sent to the internet layer
MP3 Adds the sequence number to the packet header
MP4 It establishes end to end contact
MP5 It ensures data arrives error free // It retransmits packets if lost.

2(c) One mark for name of protocol and one mark for expansion (Max 2) 2

HTTP(S) – responsible for correct transfer of files / hypertext documents that make up web pages on the world wide web

FTP – used when transferring files from a server to a client on a network

POP3 – handles the receiving of emails

IMAP – handles the receiving of emails

SMTP – handles the sending of emails

BitTorrent – provides peer-to-peer file sharing

© Cambridge University Press & Assessment 2024 Page 5 of 14


9618/31 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(a) One mark per mark point (Max 2) 3


non-composite data types
MP1 Non-composite data types can both be user-defined or primitive
MP2 Non-composite data types do not refer to other data types in their definition / contain one data type in their
definition
MP3 Non-composite data types can be primitive/enumerated/pointer

One mark per mark point (Max 2)


composite data types
MP4 Composite data types can be user-defined or primitive
MP5 Composite data types refer to other data types in their definition/contain more than one data type in their
definition
MP6 Composite data types can be record/set/class

3(b) One mark for TYPE FootballClub and ENDTYPE correct 4


One mark for every two correct declarations

Example answer
TYPE FootballClub
DECLARE TeamName : STRING
DECLARE DateOfJoining : DATE
DECLARE MainTelephone : STRING
DECLARE ManagerName : STRING
DECLARE NumberOfMembers : INTEGER
DECLARE LeaguePosition : INTEGER
ENDTYPE

© Cambridge University Press & Assessment 2024 Page 6 of 14


9618/31 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

4(a) One mark per mark point (Max 2) 2


MP1 Sequential access method searches for records one after the other
MP2 … from the physical start of the file until the record is found/the end of file.

4(b) One mark per mark point (Max 3) 3


MP1 For serial files, records are stored in chronological order
MP2 … every record needs to be checked until the record is found, or all records have been checked.
MP3 For sequential files, records are stored in order of a key field/index, and it is the key field/index that is compared.
MP4 … every record is checked until the record is found, or the key field of the current record is greater than the key
field of the target record.

Question Answer Marks

5(a) One mark per correct term (Max 3) 3


(5 + 2)
/ (9 – 3)
* 3

Complete correct answer


((5 + 2) / (9 - 3)) * 3

5(b) One mark 7 3 + 2


One mark 2 8 * - 6 /

Complete answer
7 3 + 2 8 * - 6 /

© Cambridge University Press & Assessment 2024 Page 7 of 14


9618/31 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

5(c) One mark per ring (Max 4) 4

5 7 7 10 10

17 17 12 12 12 12 120 120 12

© Cambridge University Press & Assessment 2024 Page 8 of 14


9618/31 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

6(a) One mark for working, all four columns P, Q, R and S 3


One mark for first four rows of column Z
One mark for second four rows of column Z

Working space

A B C P Q R S Z

0 0 0 1 0 0 1 1

0 0 1 1 0 0 1 1

0 1 0 0 0 0 0 0

0 1 1 0 0 0 0 0

1 0 0 1 0 0 0 0

1 0 1 1 0 1 0 1

1 1 0 0 0 0 1 1

1 1 1 0 1 0 1 1

6(b) Two marks for all five correct terms and no extras 2
One mark for any three correct terms

(Z =) A.B.C + A.B.C + A.B.C + A.B.C + A.B.C

© Cambridge University Press & Assessment 2024 Page 9 of 14


9618/31 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

6(c)(i) Two marks if all correct 2


One mark if one error present

BC
A 00 01 11 10

0 1 1 0 0

1 1 1 1 1

6(c)(ii) One mark for each correct loop (Max 2) 2

BC
A 00 01 11 10

0 1 1 0 0

1 1 1 1 1

6(c)(iii) A+B 1

Question Answer Marks

7(a) One mark per point (max 3) 3


MP1 A digital certificate is an electronic/online document.
MP2 used to authenticate/prove the identity of a website/the online identity of an individual/organisation
MP3 typically issued by a CA
MP4 For example: it contains information identifying a website owner/individual and a public key

7(b) One mark per point (max 2) 2


MP1 The digital certificate provides the public key
MP2 … that can be used to validate the private key associated with the organisation/website/digital signature

© Cambridge University Press & Assessment 2024 Page 10 of 14


9618/31 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

8(a) One mark for each correctly completed clause (Max 3) 3

(23) feature(sliding_doors).
(24) available(sliding_doors, minivan).
(25) unavailable(sliding_doors, hatchback).

8(b) (Options =) sunroof, reversing_camera 1

8(c) One mark per mark point (Max 4) 4


MP1 feature(F)
MP2 bodystyle(B)
MP3 unavailable(F, B)
MP4 all correct Boolean operators and punctuation (allow , for AND) and no additional lines of code

Example answers

may_choose_option(F, B)
IF

feature(F) AND bodystyle(B) AND NOT unavailable(F, B).

feature(F), bodystyle(B), NOT unavailable(F, B).

Question Answer Marks

9 One mark per mark point (Max 3) 3


MP1 Deep learning learns by finding hidden patterns that are undetectable to humans.
MP2 It structures algorithms in layers: input layer, hidden layers and output layer.
MP3 … to create an artificial neural network to learn and make intelligent decisions on its own.
MP4 It is trained using large quantities of unlabelled data.
MP5 Deep learning requires/uses a large number of hidden layers.
MP6 … the larger the number of layers, the higher the level of success.

© Cambridge University Press & Assessment 2024 Page 11 of 14


9618/31 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

10(a) One mark 1


The elements are sorted according to the compare function / in ascending / descending order.

10(b) One mark for each correctly completed line (Max 5) 5


DECLARE Names : ARRAY[1:100000] OF STRING
DECLARE TopOfList : INTEGER
DECLARE EndOfList : INTEGER
DECLARE CurrentItem : INTEGER
DECLARE ToFind : STRING
DECLARE Found : BOOLEAN
DECLARE NotInList : BOOLEAN
TopOfList  1
EndOfList  100000

OUTPUT "Which name do you wish to find? "


INPUT ToFind
Found  FALSE
NotInList  FALSE
WHILE Found = FALSE AND NotInList = FALSE
CurrentItem  (TopOfList + EndOfList) DIV 2
IF ToFind = Names[CurrentItem]// Names[CurrentItem] = ToFind THEN
Found  TRUE
ELSE
IF TopOfList >= EndOfList THEN
NotInList  TRUE
ELSE
IF ToFind > Names[CurrentItem] THEN
TopOfList  CurrentItem + 1
ELSE
EndOfList  CurrentItem – 1
ENDIF
ENDIF
ENDIF
ENDWHILE

© Cambridge University Press & Assessment 2024 Page 12 of 14


9618/31 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

10(b) IF Found = TRUE THEN


OUTPUT "Item found at position ", CurrentItem, " in array"
ELSE
OUTPUT "Item not in array"
ENDIF

10(c) One mark from 2


MP1 Big O for a binary search is O(Log2 n).
MP2 Big O notation is used to indicate the time/space complexity of an algorithm.

One mark from


MP3 The time taken to complete the search increases logarithmically as the number of search items increases linearly
MP4 The time taken to complete the search increases linearly as the number of search items increases exponentially
MP5 As the search field is repeatedly getting smaller, the number of comparisons made before the item is found, or the
number of items runs out, is relatively small.

© Cambridge University Press & Assessment 2024 Page 13 of 14


9618/31 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

11(a) One mark per mark point (Max 2) 2


MP1 Uses hard-wired code/control units
MP2 Uses relatively few instructions / simple instructions
MP3 Uses relatively few addressing modes
MP4 Makes use of a single-cycle for each instruction
MP5 Makes use of fixed length / fixed format instructions
MP6 Makes use of general-purpose registers
MP7 Pipelining is straightforward to apply
MP8 The design emphasis is on the software
MP9 Processor chips require few transistors.

11(b) One mark per mark point (Max 3) 3


MP1 Once the processor detects an interrupt at the start/end of the fetch-execute cycle
MP2 … the current program is temporarily stopped and the status of each register stored on the stack.
MP3 After the interrupt has been serviced/the Interrupt Service Routine (ISR) has been executed …
MP4 … the registers can be restored to its original status before the interrupt was detected // … the data can be
restored from the stack.

11(c) One mark per mark point (Max 3) 3


MP1 Pipelining adds an additional complexity // there could be a number of instructions still in the pipeline when the
interrupt is received
MP2 All the instructions currently in operation are usually discarded except for the last one/the one at write back
MP3 … the interrupt handler routine is applied to the remaining instruction.
MP4 Once the interrupt has been serviced the processor can restart with the next instruction in the sequence.

© Cambridge University Press & Assessment 2024 Page 14 of 14


Cambridge International AS & A Level

COMPUTER SCIENCE 9618/32


Paper 3 Advanced Theory May/June 2024
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge International will not enter into discussions about these mark schemes.

Cambridge International is publishing the mark schemes for the May/June 2024 series for most
Cambridge IGCSE, Cambridge International A and AS Level and Cambridge Pre-U components, and some
Cambridge O Level components.

This document consists of 14 printed pages.

© Cambridge University Press & Assessment 2024 [Turn over


9618/32 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Generic Marking Principles

These general marking principles must be applied by all examiners when marking candidate answers. They should be applied alongside the
specific content of the mark scheme or generic level descriptions for a question. Each question paper and mark scheme will also comply with these
marking principles.

GENERIC MARKING PRINCIPLE 1:

Marks must be awarded in line with:

 the specific content of the mark scheme or the generic level descriptors for the question
 the specific skills defined in the mark scheme or in the generic level descriptors for the question
 the standard of response required by a candidate as exemplified by the standardisation scripts.

GENERIC MARKING PRINCIPLE 2:

Marks awarded are always whole marks (not half marks, or other fractions).

GENERIC MARKING PRINCIPLE 3:

Marks must be awarded positively:

 marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit is given for valid answers which go beyond
the scope of the syllabus and mark scheme, referring to your Team Leader as appropriate
 marks are awarded when candidates clearly demonstrate what they know and can do
 marks are not deducted for errors
 marks are not deducted for omissions
 answers should only be judged on the quality of spelling, punctuation and grammar when these features are specifically assessed by the
question as indicated by the mark scheme. The meaning, however, should be unambiguous.

GENERIC MARKING PRINCIPLE 4:

Rules must be applied consistently, e.g. in situations where candidates have not followed instructions or in the application of generic level
descriptors.

© Cambridge University Press & Assessment 2024 Page 2 of 14


9618/32 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
GENERIC MARKING PRINCIPLE 5:

Marks should be awarded using the full range of marks defined in the mark scheme for the question (however; the use of the full mark range may
be limited according to the quality of the candidate responses seen).

GENERIC MARKING PRINCIPLE 6:

Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should not be awarded with grade thresholds or
grade descriptors in mind.

© Cambridge University Press & Assessment 2024 Page 3 of 14


9618/32 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(a) One mark per mark point (Max 2) 2


MP1 When the number of bits in the mantissa is raised, the precision / accuracy of the number represented increases //
when the number of bits in the mantissa is lowered, the precision / accuracy of the number represented reduces.
MP2 When the number of bits in the exponent is reduced, the range of numbers that can be represented is reduced //
when the number of bits in the exponent is increased, the range of possible numbers that can be represented
increases.
MP3 When the range increases the accuracy decreases // When the range decreases the accuracy increases.

1(b) One mark per mark point (Max 3) 3


 number converted to binary e.g. 54.8125 = 00110110.1101 // Fractions method 1/2 + 1/4 + 1/16 + 1/32 + 1/128 + 1/256
+ 1/1024 = 877/1024 // 32 + 16 + 4 + 2 + 0.5 + 0.25 + 0.0625 / (1/2 + 1/4 + 1/16)
 exponent = 6 // Moving binary point the correct number of places
 correct answer

Mantissa Exponent
0 1 1 0 1 1 0 1 1 0 1 0 0 1 1 0

Question Answer Marks

2(a) One mark per mark point (Max 2) 2


MP1 Protocols provide a standard set of rules that enables successful data transfer between devices.
MP2 Allows communication between devices on different platforms.
MP3 Makes communications independent of software and hardware.

2(b) One mark per mark point 2


MP1 Sending - SMTP
MP2 Receiving – POP3 // IMAP // Post Office Protocol 3

2(c) One mark per mark point (Max 3) 3


MP1 BitTorrent allows the sharing of files between thousands of users who are connected together over the internet.
MP2 It allows more users to share files with each other than would be the case with a peer-to-peer network.
MP3 Users share files directly with each other // the users’ computers are acting as peers
MP4 … no web server / central device is used // all users are of equal status.

© Cambridge University Press & Assessment 2024 Page 4 of 14


9618/32 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(a) One mark per mark point (Max 3) 3


MP1 A data type that is defined without referencing another data type.
MP2 It can be a primitive data type found in a programming language or a user-defined data type.
MP3 Example – enumerated data type / pointer data type / allow a correct example of an enumerated or pointer data
type declaration.

3(b) One mark per mark point (Max 4) 4


MP1 Type statement fully correct
MP2 DEFINE EvenNumbers
MP3 Correct list of values in brackets
MP4 : <set identifier> from Type statement used

Example answer
TYPE Numbers = SET OF INTEGER
DEFINE EvenNumbers (2, 4, 6, 8, 10, 12): Numbers

Question Answer Marks

4 One mark per mark point (Max 4) 4


MP1 Sheila’s computer uses an algorithm to generate a matching pair of keys private and public
MP2 Sheila’s computer sends Fred’s computer Sheila’s public key // Fred‘s computer acquires Sheila’s public key
MP3 Fred’s computer encrypts the document/plain text using Sheila’s public key to create cipher text
MP4 Fred’s computer sends the cipher text to Sheila’s computer The cipher text can only be decrypted using Sheila’s
private key // Sheila’s computer uses Sheila’s private key to decrypt the cipher text.

Question Answer Marks

5(a) One mark 7 2 – 8 + 2


One mark 9 5 - /

Complete answer
7 2 – 8 + 9 5 - /

© Cambridge University Press & Assessment 2024 Page 5 of 14


9618/32 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

5(b) One mark per ring (Max 4) 4

3 7

9 6 6 9 9 2

6 6 15 15 15 15 15 15 30

5(c) One mark per correct term (Max 3) 3


(a – c + b)
* (d + b)
/c

Complete correct answer


(((a – c) + b) * (d + b))/c

Or

(a – c + b) * (d + b)/c

© Cambridge University Press & Assessment 2024 Page 6 of 14


9618/32 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

6(a) One mark for working, all five columns P, Q, R, S and T 3


One mark for first four rows of column Z
One mark for second four rows of column Z

Working space

A B C P Q R S T Z

0 0 0 1 1 1 1 1 0

0 0 1 1 1 0 1 0 1

0 1 0 1 0 1 1 0 1

0 1 1 1 0 0 1 0 1

1 0 0 0 1 1 0 0 0

1 0 1 0 1 0 1 0 1

1 1 0 0 0 1 1 0 1

1 1 1 0 0 0 1 0 1

6(b) Two marks for all six correct terms only 2


One mark for any three correct terms

(Z = ) A.B.C + A.B.C + A.B.C + A.B.C + A.B.C + A.B.C

© Cambridge University Press & Assessment 2024 Page 7 of 14


9618/32 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

6(c)(i) Two marks if all correct 2


One mark if only one error present

BC
00 01 11 10
A
0 1 0 1 1

1 1 0 1 1

6(c)(ii) One mark for each correct loop (Max 2) 2

BC
00 01 11 10
A
0
0 1 1 1

1 1 0 1 1

6(c)(iii) B+C 1

Question Answer Marks

7(a) One mark per mark point (Max 2) 2


MP1 Direct access allows a record to be found in a file without other records being read.
MP2 Records are found by using the key field of the target record // the location of the record is found using a
hashing algorithm.

7(b)(i) One mark per mark point (Max 2) 2


MP1 In sequential files, an index of all key fields is kept
MP2 The index is searched for the address of the file location where the target record is stored.

© Cambridge University Press & Assessment 2024 Page 8 of 14


9618/32 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

7(b)(ii) One mark per mark point (Max 2) 2


MP1 A hashing algorithm is used on the key field of the record
MP2 … to calculate the address of the memory location where the target record is expected to be stored.
MP3 Method to find a record if it is not at the expected location e.g. linear probing, search overflow area etc.

© Cambridge University Press & Assessment 2024 Page 9 of 14


9618/32 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

8(a) One mark for each correctly completed line (Max 4) 4


DECLARE Widgets : ARRAY[1:50000] OF STRING
DECLARE TopOfList : INTEGER
DECLARE EndOfList : INTEGER
DECLARE Count : INTEGER
DECLARE ToFind : STRING
DECLARE Found : BOOLEAN
DECLARE NotInList : BOOLEAN
TopOfList  1
EndOfList  50000
OUTPUT "Enter the name of the item you wish to find "
INPUT ToFind
Found  FALSE
NotInList  FALSE
Count  TopOfList
WHILE Found = FALSE AND NotInList = FALSE // Count <= EndOfList
IF ToFind = Widgets[Count] // Widgets[Count] = ToFind THEN
Found  TRUE
ENDIF
Count  Count + 1
IF Found = FALSE AND Count > EndOfList THEN
NotInList  TRUE
ENDIF
ENDWHILE
IF Found = TRUE THEN
OUTPUT "Item found at position ", Count - 1, " in array"
ELSE
OUTPUT "Item not in array"
ENDIF

© Cambridge University Press & Assessment 2024 Page 10 of 14


9618/32 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

8(b) Max 4 4
One mark per mark point (Max 3)
MP1 Linear search sequentially checks each element of the array / list.
MP2 … until the matching element is found, or the end of the array / list is reached.
MP3 Binary search finds the mid-point of an array/list and determines which side contains the item to be found
MP4 … it discards the half of the array/list not containing the search item // … it finds the position of a target value within
an array / list by repeatedly halving the target search field.
MP5 The binary search requires the elements to be sorted // The linear search does not require the elements to be
sorted.
MP6 The binary search will usually do many fewer comparisons of records/iterations against the target than a linear
search before it finds its target.
MP7 Linear search starts at the beginning of the array/list and binary search starts in the middle of the array/list.

One mark per mark point (Max 2)


MP8 Big O for binary search is O (Log2 n)
MP9 Big O for linear search is O (n)
MP10 Big O notation is used to indicate the time / space complexity of an algorithm

© Cambridge University Press & Assessment 2024 Page 11 of 14


9618/32 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

9(a) One mark per mark point for up to two benefits (Max 2) 4
MP1 COMPATIBILTY e.g. Applications that aren’t compatible with the host computer can be run on the virtual machine
// It is possible to emulate old software on a new system by running a compatible guest operating system as a
virtual machine // Software can be tried on different OS on the same hardware.
MP2 PROTECTION e.g. The guest operating system has no effect on anything outside the virtual machine other virtual
machines or the host computer//Virtual machines are useful for testing as they will not crash the host computer if
something goes wrong // Easier to recover if software causes a system crash as virtual machine software protects
the host system.
MP3 COST e.g. No need to buy extra computers / hardware as multiple virtual machines can be implemented on the
same hardware.

One mark per mark point for up to two limitations (Max 2)


MP4 PERFORMANCE e.g. The performance of the guest operating system will not be as good on a virtual machine as
it would be on its own compatible machine because of the extra code / using more RAM/memory space // The
performance of the VM is dependent on the capabilities of the host computer // Response times cannot be
accurately measured using a virtual machine.
MP5 COMPLEXITY e.g. Building an in-house virtual machine can be expensive, time consuming and complex to
maintain / set-up.
MP6 HARDWARE/SOFTWARE ISSUES e.g. Some hardware/software can’t be emulated with a virtual machine //
Some of the host machine’s hardware can’t be directly accessed by the virtual machine.

9(b) One mark per mark point – host operating system (Max 2) 3
MP1 The host operating system is the normal operating system for the host computer / machine.
MP2 It has control of all the resources of the host computer / machine. // It can access the physical resources of the
host computer / machine.
MP3 It provides a user interface to operate the virtual machine software.
MP4 It also runs the virtual machine software.

One mark per mark point – guest operating system (Max 2)


MP5 The guest operating system runs within the virtual machine.
MP6 … it controls the virtual hardware/software during the emulation. // It accesses the actual hardware through the
virtual machine and host operating system.
MP7 It provides a virtual user interface for the emulated hardware/software.
MP8 The guest operating system runs under the control of the host operating system.

© Cambridge University Press & Assessment 2024 Page 12 of 14


9618/32 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

10(a) One mark for each correctly completed clause (Max 4) 4

Example answer
(25) client(jane).
(26) activity(surfing).
(27) choice(jane, surfing).
(28) done(jane, sailing).

10(b) (List =) frankie, erik, henry 1

10(c) One mark per mark point (Max 4) 4


MP1 client(C)
MP2 activity(A)
MP3 done(C, A)
MP4 all correct Boolean operators and punctuation (allow , for AND). There must be the correct number of terms and
no additional lines of code

Example answers

may_choose_activity(C, A)
IF

client(C) AND activity(A) AND NOT done(C, A).

client(C), activity(A), NOT (done(C, A)).

© Cambridge University Press & Assessment 2024 Page 13 of 14


9618/32 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

11 One mark per mark point (Max 3) 3


MP1 Reinforcement learning is a machine learning technique based on feedback / rewards / punishment.
MP2 … in which an agent learns to behave in an environment by performing the actions and seeing the results of the
actions.
MP3 … for each good action, the agent gets positive feedback / reward and each bad action receives negative feedback
/ punishment.
MP4 The agent learns automatically using feedback without any labelled data / specific instructions.
MP5 Adjust node weightings to achieve the correct outcome. // Using feedback to improve its performance at
accomplishing similar tasks.

© Cambridge University Press & Assessment 2024 Page 14 of 14


Cambridge International AS & A Level

COMPUTER SCIENCE 9618/33


Paper 3 Advanced Theory May/June 2024
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge International will not enter into discussions about these mark schemes.

Cambridge International is publishing the mark schemes for the May/June 2024 series for most
Cambridge IGCSE, Cambridge International A and AS Level and Cambridge Pre-U components, and some
Cambridge O Level components.

This document consists of 14 printed pages.

© Cambridge University Press & Assessment 2024 [Turn over


9618/33 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Generic Marking Principles

These general marking principles must be applied by all examiners when marking candidate answers. They should be applied alongside the
specific content of the mark scheme or generic level descriptions for a question. Each question paper and mark scheme will also comply with these
marking principles.

GENERIC MARKING PRINCIPLE 1:

Marks must be awarded in line with:

 the specific content of the mark scheme or the generic level descriptors for the question
 the specific skills defined in the mark scheme or in the generic level descriptors for the question
 the standard of response required by a candidate as exemplified by the standardisation scripts.

GENERIC MARKING PRINCIPLE 2:

Marks awarded are always whole marks (not half marks, or other fractions).

GENERIC MARKING PRINCIPLE 3:

Marks must be awarded positively:

 marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit is given for valid answers which go beyond
the scope of the syllabus and mark scheme, referring to your Team Leader as appropriate
 marks are awarded when candidates clearly demonstrate what they know and can do
 marks are not deducted for errors
 marks are not deducted for omissions
 answers should only be judged on the quality of spelling, punctuation and grammar when these features are specifically assessed by the
question as indicated by the mark scheme. The meaning, however, should be unambiguous.

GENERIC MARKING PRINCIPLE 4:

Rules must be applied consistently, e.g. in situations where candidates have not followed instructions or in the application of generic level
descriptors.

© Cambridge University Press & Assessment 2024 Page 2 of 14


9618/33 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
GENERIC MARKING PRINCIPLE 5:

Marks should be awarded using the full range of marks defined in the mark scheme for the question (however; the use of the full mark range may
be limited according to the quality of the candidate responses seen).

GENERIC MARKING PRINCIPLE 6:

Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should not be awarded with grade thresholds or
grade descriptors in mind.

© Cambridge University Press & Assessment 2024 Page 3 of 14


9618/33 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(a) One mark per mark point (Max 3) 3


MP1 conversion of exponent 001001 to 9
MP2 application of exponent to mantissa to go from 0.100111100 to 100111100 // 256 + 32 + 16 + 8 + 4 seen // 64/128
+ 8/128 + 4/128 + 2/128 + 1/128 = 79/128 // 1/2 + 1/16 + 1/32 + 1/64 + 1/128 = 79/128
MP3 correct answer = 316

1(b) One mark per mark point (Max 3) 3


MP1 number converted to binary 10011001.01 // number converted to positive 102.75, reversed bits and 1 added.
(0)1100110.11  10011001.00  10011001.01 // -128 + 16 + 8 + 1 + 0.25 = –102.75
MP2 exponent = 7 // Moving binary point the correct number of places
MP3 correct answer

Mantissa Exponent
1 0 0 1 1 0 0 1 0 1 0 0 0 1 1 1

© Cambridge University Press & Assessment 2024 Page 4 of 14


9618/33 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a) Two marks for all protocols in correct position 2


One mark for at least two protocols in correct position

Application

Transport

Internet

Link

2(b) One mark per mark point (Max 2) 2


MP1 The transport layer is responsible for delivery of data from the source host to the destination host
MP2 It is where data is broken up into packets and sent to the internet layer
MP3 Adds the sequence number to the packet header
MP4 It establishes end to end contact
MP5 It ensures data arrives error free // It retransmits packets if lost.

2(c) One mark for name of protocol and one mark for expansion (Max 2) 2

HTTP(S) – responsible for correct transfer of files / hypertext documents that make up web pages on the world wide web

FTP – used when transferring files from a server to a client on a network

POP3 – handles the receiving of emails

IMAP – handles the receiving of emails

SMTP – handles the sending of emails

BitTorrent – provides peer-to-peer file sharing

© Cambridge University Press & Assessment 2024 Page 5 of 14


9618/33 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(a) One mark per mark point (Max 2) 3


non-composite data types
MP1 Non-composite data types can both be user-defined or primitive
MP2 Non-composite data types do not refer to other data types in their definition / contain one data type in their
definition
MP3 Non-composite data types can be primitive/enumerated/pointer

One mark per mark point (Max 2)


composite data types
MP4 Composite data types can be user-defined or primitive
MP5 Composite data types refer to other data types in their definition/contain more than one data type in their
definition
MP6 Composite data types can be record/set/class

3(b) One mark for TYPE FootballClub and ENDTYPE correct 4


One mark for every two correct declarations

Example answer
TYPE FootballClub
DECLARE TeamName : STRING
DECLARE DateOfJoining : DATE
DECLARE MainTelephone : STRING
DECLARE ManagerName : STRING
DECLARE NumberOfMembers : INTEGER
DECLARE LeaguePosition : INTEGER
ENDTYPE

© Cambridge University Press & Assessment 2024 Page 6 of 14


9618/33 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

4(a) One mark per mark point (Max 2) 2


MP1 Sequential access method searches for records one after the other
MP2 … from the physical start of the file until the record is found/the end of file.

4(b) One mark per mark point (Max 3) 3


MP1 For serial files, records are stored in chronological order
MP2 … every record needs to be checked until the record is found, or all records have been checked.
MP3 For sequential files, records are stored in order of a key field/index, and it is the key field/index that is compared.
MP4 … every record is checked until the record is found, or the key field of the current record is greater than the key
field of the target record.

Question Answer Marks

5(a) One mark per correct term (Max 3) 3


(5 + 2)
/ (9 – 3)
* 3

Complete correct answer


((5 + 2) / (9 - 3)) * 3

5(b) One mark 7 3 + 2


One mark 2 8 * - 6 /

Complete answer
7 3 + 2 8 * - 6 /

© Cambridge University Press & Assessment 2024 Page 7 of 14


9618/33 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

5(c) One mark per ring (Max 4) 4

5 7 7 10 10

17 17 12 12 12 12 120 120 12

© Cambridge University Press & Assessment 2024 Page 8 of 14


9618/33 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

6(a) One mark for working, all four columns P, Q, R and S 3


One mark for first four rows of column Z
One mark for second four rows of column Z

Working space

A B C P Q R S Z

0 0 0 1 0 0 1 1

0 0 1 1 0 0 1 1

0 1 0 0 0 0 0 0

0 1 1 0 0 0 0 0

1 0 0 1 0 0 0 0

1 0 1 1 0 1 0 1

1 1 0 0 0 0 1 1

1 1 1 0 1 0 1 1

6(b) Two marks for all five correct terms and no extras 2
One mark for any three correct terms

(Z =) A.B.C + A.B.C + A.B.C + A.B.C + A.B.C

© Cambridge University Press & Assessment 2024 Page 9 of 14


9618/33 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

6(c)(i) Two marks if all correct 2


One mark if one error present

BC
A 00 01 11 10

0 1 1 0 0

1 1 1 1 1

6(c)(ii) One mark for each correct loop (Max 2) 2

BC
A 00 01 11 10

0 1 1 0 0

1 1 1 1 1

6(c)(iii) A+B 1

Question Answer Marks

7(a) One mark per point (max 3) 3


MP1 A digital certificate is an electronic/online document.
MP2 used to authenticate/prove the identity of a website/the online identity of an individual/organisation
MP3 typically issued by a CA
MP4 For example: it contains information identifying a website owner/individual and a public key

7(b) One mark per point (max 2) 2


MP1 The digital certificate provides the public key
MP2 … that can be used to validate the private key associated with the organisation/website/digital signature

© Cambridge University Press & Assessment 2024 Page 10 of 14


9618/33 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

8(a) One mark for each correctly completed clause (Max 3) 3

(23) feature(sliding_doors).
(24) available(sliding_doors, minivan).
(25) unavailable(sliding_doors, hatchback).

8(b) (Options =) sunroof, reversing_camera 1

8(c) One mark per mark point (Max 4) 4


MP1 feature(F)
MP2 bodystyle(B)
MP3 unavailable(F, B)
MP4 all correct Boolean operators and punctuation (allow , for AND) and no additional lines of code

Example answers

may_choose_option(F, B)
IF

feature(F) AND bodystyle(B) AND NOT unavailable(F, B).

feature(F), bodystyle(B), NOT unavailable(F, B).

Question Answer Marks

9 One mark per mark point (Max 3) 3


MP1 Deep learning learns by finding hidden patterns that are undetectable to humans.
MP2 It structures algorithms in layers: input layer, hidden layers and output layer.
MP3 … to create an artificial neural network to learn and make intelligent decisions on its own.
MP4 It is trained using large quantities of unlabelled data.
MP5 Deep learning requires/uses a large number of hidden layers.
MP6 … the larger the number of layers, the higher the level of success.

© Cambridge University Press & Assessment 2024 Page 11 of 14


9618/33 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

10(a) One mark 1


The elements are sorted according to the compare function / in ascending / descending order.

10(b) One mark for each correctly completed line (Max 5) 5


DECLARE Names : ARRAY[1:100000] OF STRING
DECLARE TopOfList : INTEGER
DECLARE EndOfList : INTEGER
DECLARE CurrentItem : INTEGER
DECLARE ToFind : STRING
DECLARE Found : BOOLEAN
DECLARE NotInList : BOOLEAN
TopOfList  1
EndOfList  100000

OUTPUT "Which name do you wish to find? "


INPUT ToFind
Found  FALSE
NotInList  FALSE
WHILE Found = FALSE AND NotInList = FALSE
CurrentItem  (TopOfList + EndOfList) DIV 2
IF ToFind = Names[CurrentItem]// Names[CurrentItem] = ToFind THEN
Found  TRUE
ELSE
IF TopOfList >= EndOfList THEN
NotInList  TRUE
ELSE
IF ToFind > Names[CurrentItem] THEN
TopOfList  CurrentItem + 1
ELSE
EndOfList  CurrentItem – 1
ENDIF
ENDIF
ENDIF
ENDWHILE

© Cambridge University Press & Assessment 2024 Page 12 of 14


9618/33 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

10(b) IF Found = TRUE THEN


OUTPUT "Item found at position ", CurrentItem, " in array"
ELSE
OUTPUT "Item not in array"
ENDIF

10(c) One mark from 2


MP1 Big O for a binary search is O(Log2 n).
MP2 Big O notation is used to indicate the time/space complexity of an algorithm.

One mark from


MP3 The time taken to complete the search increases logarithmically as the number of search items increases linearly
MP4 The time taken to complete the search increases linearly as the number of search items increases exponentially
MP5 As the search field is repeatedly getting smaller, the number of comparisons made before the item is found, or the
number of items runs out, is relatively small.

© Cambridge University Press & Assessment 2024 Page 13 of 14


9618/33 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

11(a) One mark per mark point (Max 2) 2


MP1 Uses hard-wired code/control units
MP2 Uses relatively few instructions / simple instructions
MP3 Uses relatively few addressing modes
MP4 Makes use of a single-cycle for each instruction
MP5 Makes use of fixed length / fixed format instructions
MP6 Makes use of general-purpose registers
MP7 Pipelining is straightforward to apply
MP8 The design emphasis is on the software
MP9 Processor chips require few transistors.

11(b) One mark per mark point (Max 3) 3


MP1 Once the processor detects an interrupt at the start/end of the fetch-execute cycle
MP2 … the current program is temporarily stopped and the status of each register stored on the stack.
MP3 After the interrupt has been serviced/the Interrupt Service Routine (ISR) has been executed …
MP4 … the registers can be restored to its original status before the interrupt was detected // … the data can be
restored from the stack.

11(c) One mark per mark point (Max 3) 3


MP1 Pipelining adds an additional complexity // there could be a number of instructions still in the pipeline when the
interrupt is received
MP2 All the instructions currently in operation are usually discarded except for the last one/the one at write back
MP3 … the interrupt handler routine is applied to the remaining instruction.
MP4 Once the interrupt has been serviced the processor can restart with the next instruction in the sequence.

© Cambridge University Press & Assessment 2024 Page 14 of 14


Cambridge International AS & A Level

COMPUTER SCIENCE 9618/41


Paper 4 Practical May/June 2024
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge International will not enter into discussions about these mark schemes.

Cambridge International is publishing the mark schemes for the May/June 2024 series for most
Cambridge IGCSE, Cambridge International A and AS Level and Cambridge Pre-U components, and some
Cambridge O Level components.

This document consists of 38 printed pages.

© Cambridge University Press & Assessment 2024 [Turn over


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Generic Marking Principles

These general marking principles must be applied by all examiners when marking candidate answers. They should be applied alongside the
specific content of the mark scheme or generic level descriptions for a question. Each question paper and mark scheme will also comply with these
marking principles.

GENERIC MARKING PRINCIPLE 1:

Marks must be awarded in line with:

 the specific content of the mark scheme or the generic level descriptors for the question
 the specific skills defined in the mark scheme or in the generic level descriptors for the question
 the standard of response required by a candidate as exemplified by the standardisation scripts.

GENERIC MARKING PRINCIPLE 2:

Marks awarded are always whole marks (not half marks, or other fractions).

GENERIC MARKING PRINCIPLE 3:

Marks must be awarded positively:

 marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit is given for valid answers which go beyond
the scope of the syllabus and mark scheme, referring to your Team Leader as appropriate
 marks are awarded when candidates clearly demonstrate what they know and can do
 marks are not deducted for errors
 marks are not deducted for omissions
 answers should only be judged on the quality of spelling, punctuation and grammar when these features are specifically assessed by the
question as indicated by the mark scheme. The meaning, however, should be unambiguous.

GENERIC MARKING PRINCIPLE 4:

Rules must be applied consistently, e.g. in situations where candidates have not followed instructions or in the application of generic level
descriptors.

© Cambridge University Press & Assessment 2024 Page 2 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
GENERIC MARKING PRINCIPLE 5:

Marks should be awarded using the full range of marks defined in the mark scheme for the question (however; the use of the full mark range may
be limited according to the quality of the candidate responses seen).

GENERIC MARKING PRINCIPLE 6:

Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should not be awarded with grade thresholds or
grade descriptors in mind.

© Cambridge University Press & Assessment 2024 Page 3 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(a) 1 mark for: 1


 Declaration of (global) array with identifier DataStored (Integer and 20 spaces)
and NumberItems (Integer)
e.g.
Java
public static Integer[] DataStored = new Integer[20];
public static Integer NumberItems= 0;

VB.NET
Dim DataStored(19) As Integer
Dim NumberStored As Integer = 0

Python
global DataStored #integer
global NumberItems #Integer 20 items

© Cambridge University Press & Assessment 2024 Page 4 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(b) 1 mark each 5


 Procedure heading (and close where appropriate) with no parameter.
 Prompt/output of suitable message to request the input of the quantity of numbers
and reading in quantity of numbers and storing/using …
 … each input in next space in DataStored
e.g.
Java
public static void Initialise(){
Scanner scanner = new Scanner(System.in);
Integer Quantity = 0;
do{
System.out.println("How many numbers will you enter up to 20?");
Quantity = Integer.parseInt(scanner.nextLine());
}while(Quantity <= 0 || Quantity > 20);
for(Integer X = 0; X < Quantity; X++){
System.out.println("Enter number");
DataStored[NumberItems] = Integer.parseInt(scanner.nextLine());
NumberItems++;

VB.NET
Sub Initialise()
Console.WriteLine("How many numbers will you enter?")
Dim Quantity As Integer
Do
Quantity = Console.ReadLine()
Loop Until (Quantity > 0 And Quantity < 21)
For Count = 0 To Quantity - 1
Console.WriteLine("Enter number")
DataStored(NumberStored) = Console.ReadLine()
NumberStored += 1
Next
End Sub

© Cambridge University Press & Assessment 2024 Page 5 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(b) Python
def Initialise():
global DataStored
global NumberItems
Valid = False
while(Valid == False):
NumberItems = int(input("How many numbers will you enter?")) #loop until < 20
if NumberItems > 0 and NumberItems< 21:
Valid = True
for Count in range(0, NumberItems):
DataStored.append(int(input("Enter number")))

1(c)(i) 1 mark each: 2


 Storing 0 in NumberItems and then calling Initialise()
 Outputting all contents of array DataStored
e.g.
Java
public static Integer NumberItems= 0;
Initialise();
for(Integer X = 0; X < NumberItems; X++){
System.out.println(DataStored[X]);

VB.NET
NumberItems = 0
Initialise()
For X = 0 To NumberItems - 1
Console.WriteLine(DataStored(X))
Next

Python
NumberItems = 0
Initialise()
print(DataStored)

© Cambridge University Press & Assessment 2024 Page 6 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(c)(ii) 1 mark each 2


 Output showing quantity entered twice (30 and 5) with first being invalid
 Array output 3 9 4 1 2
e.g.

© Cambridge University Press & Assessment 2024 Page 7 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(d)(i) 1 mark each 4


 Procedure header (and end where appropriate)
and looping through each array element
 Working inner loop …
 …comparison of elements…
 …swapping of elements
e.g.
Java
public static void BubbleSort(){
Integer Temp = 0;
for(Integer Count = 0; Count < NumberItems; Count++){
for(Integer Count2 = 0; Count2 < NumberItems - 1; Count2++){
if(DataStored[Count2] > DataStored[Count]){
Temp = DataStored[Count2];
DataStored[Count2] = DataStored[Count];
DataStored[Count] = Temp;
}
}
}
}
VB.NET
Sub BubbleSort()
Dim Temp As Integer
For Count = 0 To NumberStored - 1
For Count2 = 0 To NumberStored - 2
If (DataStored(Count2) > DataStored(Count)) Then
Temp = DataStored(Count) DataStored(Count) = DataStored(Count2)
DataStored(Count2) = Temp
End If
Next
Next
End Sub

© Cambridge University Press & Assessment 2024 Page 8 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(d)(i) Python
def BubbleSort():
global DataStored
global NumberItems
for Count in range(0, NumberItems):
for Count2 in range(0, NumberItems-1):
if DataStored[Count2] > DataStored[Count]:
DataStored[Count2], DataStored[Count] = DataStored[Count],
DataStored[Count2]

1(d)(ii) 1 mark for calling BubbleSort() and outputting array contents after 1
e.g.
VB.NET
BubbleSort()
For X = 0 To NumberStored - 1
Console.WriteLine(DataStored(X))
Next

e.g. Java
BubbleSort();
for(Integer X = 0; X < NumberItems; X++){
System.out.println(DataStored[X]);
}
e.g. Python
BubbleSort()
print(DataStored)

1(d)(iii) 1 mark for screenshot showing the inputs and the values in the correct order 1
e.g.

© Cambridge University Press & Assessment 2024 Page 9 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(e)(i) 1 mark each 6


 Function header BinarySearch taking DataToFind as a parameter
 Calculating the mid value (First + Last) \ 2 or equivalent inside loop
 Checking if the data at mid is the parameter and returning mid inside loop
 If DataToFind < mid, updating Last/Upper with mid – 1 inside loop
 If DataToFind > mid, updating First/Lower with mid + 1 inside loop
 Returning -1 when not found and a suitable loop with end criteria
e.g.
Java
public static Integer BinarySearch(Integer DataToFind){
Integer MidValue = 0;
Integer First = 0;
Integer Last = NumberItems;
while (First <= Last){
MidValue = (First + Last) / 2;
if(DataToFind == DataStored[MidValue]){
return MidValue;
}
if(DataToFind < DataStored[MidValue]){
Last = MidValue - 1;
}else{
First = MidValue + 1;
}
}
return -1;
}

© Cambridge University Press & Assessment 2024 Page 10 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(e)(i) VB.NET
Function BinarySearch(DataToFind)
Dim First As Integer = 0
Dim Last As Integer = NumberItems
Dim MidValue As Integer
While (First <= Last)
MidValue = (First + Last) / 2
If DataToFind = DataStored(MidValue) Then
Return MidValue
End If
If DataToFind < DataStored(MidValue) Then
Last = MidValue - 1
Else
First = MidValue + 1
End If
End While
Return -1
End Function

Python
def BinarySearch(DataToFind):
global DataStored
global NumberItems
First = 0
Last= NumberItems
while(First <= Last):
MidValue = int((First + Last) / 2)

if DataToFind == DataStored[MidValue]:
return MidValue
if DataToFind < DataStored[MidValue]:
Last = MidValue - 1
else:
First = MidValue + 1

return -1

© Cambridge University Press & Assessment 2024 Page 11 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(e)(ii) 1 mark each: 3


 Taking number as input
… calling BinarySearch with input
 Outputting value returned
e.g.
Java
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a number to find");
Integer Search = Integer.parseInt(scanner.nextLine());
System.out.println(BinarySearch(Search));

VB.NET
Console.WriteLine("Enter a number to find")
Dim Search As Integer = Console.ReadLine()
Console.WriteLine(BinarySearch(Search))

Python
Search = int(input("Enter a number to find"))
print(BinarySearch(Search))

© Cambridge University Press & Assessment 2024 Page 12 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(e)(iii) 1 mark for each test 2


e.g.
Test 1 – Accept found in index 16

Test 2

© Cambridge University Press & Assessment 2024 Page 13 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a)(i) 1 mark each to max 4 4


 Class Tree declaration (and end where appropriate)
 All 5 attributes declared as private with correct identifiers and data types
 Constructor header (and end) taking 5 parameters
 Constructor assigns parameters to attributes
e.g.
Java
class Tree{
private String TreeName;
private Integer HeightGrowth;
private Integer MaxWidth;
private Integer MaxHeight;
private String Evergreen;

public Tree(String Name, Integer HGrowth, Integer MaxH, Integer MaxW, String
PEvergreen){
TreeName = Name;
HeightGrowth = HGrowth;
MaxWidth = MaxW;
MaxHeight = MaxH;
Evergreen = PEvergreen;
}}

© Cambridge University Press & Assessment 2024 Page 14 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a)(i) VB.NET
Class Tree
Private TreeName As String
Private HeightGrowth As Integer
Private MaxHeight As Integer
Private MaxWidth As Integer
Private Evergreen As String
Sub New(Name, HGrowth, MaxH, MaxW, PEvergreen)
TreeName = Name
HeightGrowth = HGrowth
MaxHeight = MaxH
MaxWidth = MaxW
Evergreen = PEvergreen
End Sub
End Class

Python
class Tree:
def __init__(self, Name, HGrowth, MaxH, MaxW, PEvergreen):
self.__TreeName = Name
self.__HeightGrowth = HGrowth
self.__MaxHeight = MaxH
self.__MaxWidth = MaxW
self.__Evergreen = PEvergreen

© Cambridge University Press & Assessment 2024 Page 15 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a)(ii) 1 mark each 3


 1 get method with no parameter …
 … returning correct attribute
 Remaining 4 correct
e.g.
Java
public String GetTreeName(){
return TreeName;
}
public Integer GetGrowth(){
return HeightGrowth;
}
public Integer GetMaxWidth(){
return MaxWidth;
}
public Integer GetMaxHeight(){
return MaxHeight;
}
public String GetEvergreen(){
return Evergreen;
}

© Cambridge University Press & Assessment 2024 Page 16 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a)(ii) VB.NET
Function GetTreeName()
Return TreeName
End Function
Function GetMaxHeight()
Return MaxHeight
End Function
Function GetMaxWIdth()
Return MaxWidth
End Function
Function GetGrowth()
Return HeightGrowth
End Function
Function GetEvergreen()
Return Evergreen
End Function

Python
def GetTreeName(self):
return self.__TreeName
def GetMaxHeight(self):
return self.__MaxHeight
def GetMaxWidth(self):
return self.__MaxWidth
def GetGrowth(self):
return self.__HeightGrowth
def GetEvergreen(self):
return self.__Evergreen

© Cambridge University Press & Assessment 2024 Page 17 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
2(b) 1 mark for: 7
 appropriate use of exception handling, with catch and output
1 mark each to max 6
 Function header (and end where appropriate) and declaration of array (of type Tree with min 9 elements)
 Opening text file Trees.txt to read and closing the file
 Reading each line of text (until EOF, or 9 times)
 Splitting each line into the 5 elements
… casting height growth, max height and max width to integers
… creating a new object of type Tree with the 5 values
… storing each object in the array and returning the array
e.g.
Java
public static Tree[] ReadData(){
String TextFile = "Trees.txt";
String[] TempData = new String[5];
Tree[] TreeData = new Tree[20];
String Line;
try{
FileReader f = new FileReader(TextFile);
BufferedReader Reader = new BufferedReader(f);
for(Integer X = 0; X < 9; X++){
try{
Line = Reader.readLine();
TempData = Line.split(",");
TreeData[X] = new Tree(TempData[0], Integer.parseInt(TempData[1]),
Integer.parseInt(TempData[2]), Integer.parseInt(TempData[3]), TempData[4]);
}catch(IOException ex){}
}
try{
Reader.close();
}catch(IOException ex){}

}catch(FileNotFoundException e){
System.out.println("File not found");
}
return TreeData;
}

© Cambridge University Press & Assessment 2024 Page 18 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(b) VB.NET
Function ReadData()
Dim TreeObjects(10) As Tree
Dim TextFile As String = "Trees.txt"
try
Dim FileReader As New System.IO.StreamReader(TextFile)
Dim TreeData(10) As String
Dim TreeSplit() As String
For Count = 0 To 8
TreeData(Count) = FileReader.ReadLine()

Next Count
FileReader.Close()

For X = 0 To 8

TreeSplit = TreeData(X).Split(",")
TreeObjects(X) = New Tree(TreeSplit(0), Integer.Parse(TreeSplit(1)),
Integer.Parse(TreeSplit(2)), Integer.Parse(TreeSplit(3)), TreeSplit(4))
Next X
Catch ex As Exception
Console.WriteLine ("invalid file")
End Try
Return TreeObjects

End Function

© Cambridge University Press & Assessment 2024 Page 19 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(b) Python
def ReadData():
TreeObjects=[]
try:
File = open("Trees.txt")
TreeData = []
TreeData = File.read().split("\n")
SplitTrees = []
for Item in TreeData:
SplitTrees.append(Item.split(","))
File.close()
for Item in SplitTrees:

TreeObjects.append(Tree(Item[0],int(Item[1]),int(Item[2]),int(Item[3]),Item[4]))
except IOError:
print ("invalid file")
return TreeObjects

© Cambridge University Press & Assessment 2024 Page 20 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(c) 1 mark each 4


 Procedure heading (and end) taking one parameter (of type Tree)
and using get methods to access tree name, height, width, growth
 Outputs all 4 attributes (TreeName, MaxHeight, MaxWidth, GetGrowth)
 Checks if it is evergreen…
… correct messages are output if evergreen and otherwise

e.g.
Java
public static void PrintTrees(Tree TreeItem){
String Final = "does not lose its leaves";
if((TreeItem.GetEvergreen()).compareTo("No") == 0){
Final = "loses its leaves each year";
}
System.out.println(TreeItem.GetTreeName() + " has a maximum height " +
TreeItem.GetMaxHeight() + " a maximum width " + TreeItem.GetMaxWidth() + " and grows " +
TreeItem.GetGrowth() + " cm a year. It " + Final);
}

VB.NET
Sub PrintTrees(Item)
Dim Final As String = "does not lose its leaves"
If (Item.GetEvergreen() = "No") Then
Final = "loses its leaves each year"
End If
Console.WriteLine(Item.GetTreeName() & " has a maximum height " &
Item.GetMaxHeight() & " a maximum width " & Item.GetMaxWidth() & " and grows " &
Item.GetGrowth() & "cm a year. It" & Final)
End Sub

© Cambridge University Press & Assessment 2024 Page 21 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(c) Python
def PrintTrees(Item):

Final = "does not lose its leaves"


if Item.GetEvergreen() == "No":
Final = "loses its leaves each year"
print(Item.GetTreeName(), "has a maximum height", Item.GetMaxHeight(),"a maximum
width",Item.GetMaxWidth(),"and grows", Item.GetGrowth(),"cm a year. It",Final)

2(d)(i)  1 mark each 2


 Calling ReadData() and storing/using return value (as array of type Tree)…
…calling PrintTrees() with first object in returned array as parameter

e.g.
Java
Tree[] TreeData = new Tree[20];
TreeData = ReadData();
PrintTrees(TreeData[0]);

VB.NET
Sub Main(args As String())
Dim TreeObjects(10) As Tree
TreeObjects = ReadData()
PrintTrees(Treeobjects(0))
End Sub

Python
TreeObjects = ReadData()
PrintTrees(TreeObjects[0])

2(d)(ii) Screenshot showing output 1

© Cambridge University Press & Assessment 2024 Page 22 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(e)(i) 1 mark each to max 6 6


 Procedure header (and close) taking array of Tree objects as a parameter
and reading evergreen, max height and max width once as input from the user

 Looping through each array object …


 … comparing each width input >= MaxWidth, height input >= MaxHeight
 … comparing each evergreen input with Evergreen
… when all true (all requirements met) - appending object in new array
 Calling PrintTrees() with each valid object
 Outputting suitable message if no trees appropriate

e.g.
Java
public static void ChooseTree(Tree[] Trees){
Scanner scanner = new Scanner(System.in);
System.out.println("Do you want a tree that loses its leaves (enter lose), or keeps
its leaves (enter keep)") ;
String Evergreen = (scanner.nextLine());
System.out.println("What is the maximum tree height in cm");
Integer MaxHeight = Integer.parseInt(scanner.nextLine());
System.out.println("What is the maximum tree width in cm");
Integer MaxWidth = Integer.parseInt(scanner.nextLine());
Tree[] Options = new Tree[20];
String keep;
Tree Selected;
Boolean Valid = false;
if(((Evergreen.toLowerCase()).compareTo("keep") == 0) ||
((Evergreen.toLowerCase()).compareTo("keep leaves") == 0) ||
((Evergreen.toLowerCase()).compareTo("keeps its leaves") == 0)){
keep = "Yes";
}else{
keep = "No";
}
Integer Counter = 0;
for(Integer X = 0; X < 9; X++){

© Cambridge University Press & Assessment 2024 Page 23 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(e)(i) if((Trees[X].GetMaxHeight() <= MaxHeight) && (Trees[X].GetMaxWidth() <=


MaxWidth) && (keep.compareTo(Trees[X].GetEvergreen())==0)){
Options[Counter] = Trees[X];
PrintTrees(Trees[X]);
Counter = Counter + 1;
}
}
if(Counter == 0){
System.out.println("No suitable trees");
}
}

VB.NET
Sub ChooseTree(Trees)
Console.WriteLine("Do you want a tree that loses its leaves (enter lose), or keeps
its leaves (enter keep)")
Dim Evergreen As String = Console.ReadLine()
Console.WriteLine("What is the maximum tree height in cm")
Dim MaxHeight As Integer = Console.ReadLine()
Console.WriteLine("What is the maximum tree width in cm")
Dim MaxWidth As Integer = Console.ReadLine()
Dim Options(0 To 9) As Tree
Dim keep As String
Dim Valid As Boolean
Dim Selected As Tree
If Evergreen.ToLower() = "keep" Or Evergreen.ToLower() = "keep leaves" Or
Evergreen.ToLower() = "keeps its leaves" Then
keep = "Yes"
Else
keep = "No"

© Cambridge University Press & Assessment 2024 Page 24 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(e)(i) End If
Dim count As Integer = 0
For x = 0 To 8
If Trees(x).GetMaxHeight() <= MaxHeight And Trees(x).GetMaxWidth() <= MaxWidth
And keep = Trees(x).GetEvergreen() Then
Options(count) = Trees(x)
PrintTrees(Trees(x))
count = count + 1
End If
Next x
If count = 0 Then
Console.WriteLine("No suitable trees")
End If
End Sub

Python
def ChooseTree(Trees):
Evergreen = input("Do you want a tree that loses its leaves (enter lose), or keeps its
leaves (enter keep)")
MaxHeight = int(input("What is the maximum tree height in cm"))
MaxWidth = int(input("What is the maximum tree width in cm"))
Options = []
if Evergreen.lower() == "keep" or Evergreen.lower() == "keep leaves" or
Evergreen.lower() == "keeps its leaves":
keep = "Yes"
else:
keep = "No"
for Item in Trees:

if Item.GetMaxHeight() <= MaxHeight and Item.GetMaxWidth() <= MaxWidth and keep ==


Item.GetEvergreen():
Options.append(Item)
PrintTrees(Item)
if len(Options) == 0:
print("No suitable trees")

© Cambridge University Press & Assessment 2024 Page 25 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(e)(ii) 1 mark each to max 2


 Taking tree name and initial height as input
 Finding the tree, calculating and outputting the number of years to get to maximum height
VB.NET
Valid = False
Dim Start As Integer
Dim Years As Single
Dim Choice As String
While Valid = False
Console.WriteLine("Enter the name of the tree you want")
Choice = Console.ReadLine()
For X = 0 To count - 1
If Options(X).GetTreeName() = Choice Then
Valid = True
Selected = Options(X)
Console.WriteLine("Enter the height of the tree you would like to start with in
cm")
Start = Console.ReadLine()
Years = (Selected.GetMaxHeight() - Start) / Selected.GetGrowth()
Console.WriteLine("Your tree should be full height in approximately " & Years &
" years")
End If
Next X
End While

© Cambridge University Press & Assessment 2024 Page 26 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(e)(ii) Java
Integer Start;
Float Height;
Float Growth;
Float Years;
while(Valid == false){
System.out.println("Enter the name of the tree you want");
String Choice = scanner.nextLine();
for(Integer X = 0; X < Counter; X++){
if((Options[X].GetTreeName()).compareTo(Choice)==0){
Valid = true;
Selected = Options[X];
System.out.println("Enter the height of the tree you would like to start
with in cm");
Start = Integer.parseInt(scanner.nextLine());
Height = (Selected.GetMaxHeight()).floatValue();
Growth = (Selected.GetGrowth()).floatValue();
Years = (Height - Start) / Growth;
System.out.println("Your tree should be full height in approximately "+
Years + " years");
}
}
}

Python:
Valid = False
while Valid == False:
Choice = input("Enter the name of the tree you want")
for Item in Options:
if Item.GetTreeName() == Choice:
Valid = True
Selected = Item
Start = int(input("Enter the height of the tree you would like to start with in
cm"))
Years = (Selected.GetMaxHeight() - Start)/Selected.GetGrowth()
print("Your tree should be full height in approximately", Years,"years")

© Cambridge University Press & Assessment 2024 Page 27 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(e)(iii) 1 mark each 2


 Screenshot shows the user requirements input (height 400, width 200, evergreen) and outputs the correct trees (Blue
conifer and green conifer)
 Screenshot shows the tree selection input (Blue Conifer with height 100) and outputs the correct result (3 years / 3.75
/ 4 years)

© Cambridge University Press & Assessment 2024 Page 28 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(a) 1 mark each 1


 QueueData as 1D (string) array initialised to 20 null values
and QueueHead initialised to -1, QueueTail initialised to -1
e.g.
Java
class Queue{
public static String[] QueueData = new String[20];
public static Integer QueueHead;
public static Integer QueueTail;
public static void main(String args[]){
for(Integer x = 0; x < 20; x++){
QueueData[x] = "";
}
QueueHead = -1;
QueueTail = -1;
}
}
VB.NET
Dim QueueData(0 To 20) As String
Dim QueueHead As Integer = -1
Dim QueueTail As Integer = -1
Sub Main(args As String())
For x = 0 To 19
QueueData(x) = ""
Next
End Sub

Python
global QueueData
global QueueHead
global QueueTail
QueueData = []
for x in range(0, 20):
QueueData.append("")
QueueHead = -1
QueueTail = -1

© Cambridge University Press & Assessment 2024 Page 29 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(b) 1 mark each 4


 Function header (and end) taking one parameter and returns a Boolean value in all instances
 Checks if queue is full and returns FALSE
 (If not full) Inserts data item to QueueTail + 1
and increments QueueTail
and returns TRUE
 Assigns QueueHead to 0 when first element is entered (this can come from incrementing)
e.g.
Java
public static Boolean Enqueue(String DataToInsert){
if(QueueTail == 19){
return false;
}else if(QueueHead == -1){
QueueHead = 0;
}
QueueTail = QueueTail + 1;
QueueData[QueueTail] = DataToInsert.substring(0,6);
return true;
}
VB.NET
Function Enqueue(ByVal DataToInsert)
If QueueTail = 19 Then
Return False
ElseIf QueueHead = -1 Then
QueueHead = 0
End If
QueueTail = QueueTail + 1
QueueData(QueueTail) = DataToInsert
Return True
End Function

© Cambridge University Press & Assessment 2024 Page 30 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(b) Python
def Enqueue(DataToInsert):
global QueueData
global QueueHead
global QueueTail
if QueueTail == 19:
return False
elif QueueHead == -1:
QueueHead = 0
QueueTail = QueueTail + 1
QueueData.append(DataToInsert)
return True

© Cambridge University Press & Assessment 2024 Page 31 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(c) 1 mark each 3


 Dequeue function header (and end) returning a string in all cases
 Check if queue is empty
and return "false"
 (otherwise) remove value at QueueHead
and increment QueueHead
and return value from array
e.g.
Java
public static String Dequeue(){
if(QueueHead < 0 || QueueHead > 20 || QueueHead > QueueTail){
return "false";
}
QueueHead++;
return QueueData[QueueHead-1];
}
VB.NET
Function Dequeue()
If QueueHead < 0 Or QueueHead > 20 Or QueueHead > QueueTail Then
Return "false"
Else
QueueHead = QueueHead + 1
Return QueueData(QueueHead - 1)
End If
End Function

© Cambridge University Press & Assessment 2024 Page 32 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(c) Python
def Dequeue():
global QueueData
global QueueHead
global QueueTail
if QueueHead < 0 or QueueHead > 20 or QueueHead > QueueTail:
return False
else:
QueueHead = QueueHead + 1

return QueueData[QueueHead-1]

3(d)(i) 1 mark each to max 6 6


 StoreItems header (function/procedure and end where appropriate)
and takes 10 inputsi
 Input is split and first 6 characters used in calculation (as integers) …
 … multiplication by 1 and 3 alternately, adding to total, dividing by 10, rounding down/cast int …
 … comparing check digit to character in position 6
 … including comparison of X for 10

 Calling Enqueue with first 6 characters when valid


 … outputting appropriate message on return (for both inserted and queue full)
 Counts and outputs number of invalid inputs
e.g.
Java
public static void StoreItems(){
Integer Count = 0;
Integer Total = 0;
String Data;
Boolean Result;
Scanner scanner = new Scanner(System.in);
for(Integer X = 0; X < 10; X++){
System.out.println("Enter data");
Data = scanner.nextLine();
Total = Integer.parseInt(Data.substring(0,1)) +

© Cambridge University Press & Assessment 2024 Page 33 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(d)(i) Integer.parseInt(Data.substring(1,2)) * 3 + Integer.parseInt(Data.substring(2,3)) +


Integer.parseInt(Data.substring(3,4)) * 3 + Integer.parseInt(Data.substring(4,5)) +
Integer.parseInt(Data.substring(5,6)) * 3;
Total = Total / 10;
if((Total == 10 && Data.substring(6).compareTo("X")==0)){
Result = Enqueue(Data);
if(Result == true){
System.out.println("Inserted item");
}else{
System.out.println("Queue full");
}
}else if(Total == Integer.parseInt(Data.substring(6,7))){
Result = Enqueue(Data);
if(Result == true){
System.out.println("Inserted item");
}else{
System.out.println("Queue full");
}
}else{
Count = Count + 1;
}
}

System.out.println("There were " + Count + " invalid items");


}

VB.NET
Sub StoreItems()

Dim Count As Integer = 0


Dim Total As Integer = 0
Dim Data As String
Dim Result As Boolean
For X = 0 To 9
Console.WriteLine("Enter data")
Data = Console.ReadLine()

© Cambridge University Press & Assessment 2024 Page 34 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(d)(i) Total = Integer.Parse(Data.Substring(0, 1)) + Integer.Parse(Data.Substring(1, 1)) *


3 + Integer.Parse(Data.Substring(2, 1)) + Integer.Parse(Data.Substring(3, 1)) * 3 +
Integer.Parse(Data.Substring(4, 1)) + Integer.Parse(Data.Substring(5, 1)) * 3
Total = Total \ 10
If (Total = 10 And Data.Substring(6, 1) = "X") Then
Result = Enqueue(Data.Substring(0, 6))
If Result = True Then
Console.WriteLine("Inserted item")
Else
Console.WriteLine("Queue full")
End If
ElseIf Total = Integer.Parse(Data.Substring(6, 1)) Then
Result = Enqueue(Data)
If Result = True Then
Console.WriteLine("Inserted item")
Else
Console.WriteLine("Queue full")
End If
Else
Count = Count + 1
End If
Next
Console.WriteLine("There were " & Count & " invalid items")

End Sub

© Cambridge University Press & Assessment 2024 Page 35 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(d)(i) Python
def StoreItems():
global QueueData
global QueueHead
global QueueTail
Count = 0
for X in range(0, 10):
Data = input("Enter data")
Total= int(Data[0]) + int(Data[1]) * 3 + int(Data[2]) + int(Data[3]) * 3 +
int(Data[4]) + int(Data[5]) * 3
Total = int(Total / 10)
if((Total == 10 and Data[6] == "X") or (Total == int(Data[6]))):
Result = Enqueue(Data[0:6])

if(Result == True):
print("Inserted item")
else:
print("Queue full")
else:
Count = Count + 1

print("There were", Count,"Invalid items")

© Cambridge University Press & Assessment 2024 Page 36 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(d)(ii)  Calling StoreItems() 1


and Dequeue() once
and outputting a suitable message if the queue was empty
and outputting the returned value if the queue was not empty
e.g.
Java
public static void main(String args[]){
for(Integer x = 0; x < 20; x++){
QueueData[x] = "";
}
QueueHead = -1;
QueueTail = -1;
StoreItems();
String Value = Dequeue();
if(Value.compareTo("false") == 0){
System.out.println("No data items");
}else{
System.out.println("Item code " + Value);
}
}
VB.NET
Sub Main(args As String())
For x = 0 To 19
QueueData(x) = ""
Next
StoreItems()
Dim ReturnValue As String = Dequeue()
If (ReturnValue = "false") Then
Console.WriteLine("No data items")
Else
Console.WriteLine("Item code " & ReturnValue)
End If

End Sub

© Cambridge University Press & Assessment 2024 Page 37 of 38


9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(d)(ii) Python
QueueData = []
for x in range(0, 20):
QueueData.append("")
QueueHead = -1
QueueTail = -1
StoreItems()

Value = Dequeue()
if Value == False:
print("No data items")
else:
print("Item code", Value)

3(d)(iii) 1 mark each 2


 Data input of 10 values and output a message saying there are 4 invalid items
 999999 output
e.g.

© Cambridge University Press & Assessment 2024 Page 38 of 38


Cambridge International AS & A Level

COMPUTER SCIENCE 9618/42


Paper 4 Practical May/June 2024
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge International will not enter into discussions about these mark schemes.

Cambridge International is publishing the mark schemes for the May/June 2024 series for most
Cambridge IGCSE, Cambridge International A and AS Level and Cambridge Pre-U components, and some
Cambridge O Level components.

This document consists of 50 printed pages.

© Cambridge University Press & Assessment 2024 [Turn over


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Generic Marking Principles

These general marking principles must be applied by all examiners when marking candidate answers. They should be applied alongside the
specific content of the mark scheme or generic level descriptions for a question. Each question paper and mark scheme will also comply with these
marking principles.

GENERIC MARKING PRINCIPLE 1:

Marks must be awarded in line with:

 the specific content of the mark scheme or the generic level descriptors for the question
 the specific skills defined in the mark scheme or in the generic level descriptors for the question
 the standard of response required by a candidate as exemplified by the standardisation scripts.

GENERIC MARKING PRINCIPLE 2:

Marks awarded are always whole marks (not half marks, or other fractions).

GENERIC MARKING PRINCIPLE 3:

Marks must be awarded positively:

 marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit is given for valid answers which go beyond
the scope of the syllabus and mark scheme, referring to your Team Leader as appropriate
 marks are awarded when candidates clearly demonstrate what they know and can do
 marks are not deducted for errors
 marks are not deducted for omissions
 answers should only be judged on the quality of spelling, punctuation and grammar when these features are specifically assessed by the
question as indicated by the mark scheme. The meaning, however, should be unambiguous.

GENERIC MARKING PRINCIPLE 4:

Rules must be applied consistently, e.g. in situations where candidates have not followed instructions or in the application of generic level
descriptors.

© Cambridge University Press & Assessment 2024 Page 2 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
GENERIC MARKING PRINCIPLE 5:

Marks should be awarded using the full range of marks defined in the mark scheme for the question (however; the use of the full mark range may
be limited according to the quality of the candidate responses seen).

GENERIC MARKING PRINCIPLE 6:

Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should not be awarded with grade thresholds or
grade descriptors in mind.

© Cambridge University Press & Assessment 2024 Page 3 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(a) 1 mark each to max 6 6


 Procedure declaration (and end where appropriate) taking (string) parameter
 Declaration of array to store the data read (type string, suitable number of elements e.g. 150)
 Opening file to read…
 ... using exception handling with try and catch and output
 Reading in the data for each line in that file and storing in array…
 … removing carriage return (Java, Python)
 Counting the number of words
 Closing the file (might be within the Python opening file statement)

e.g.

Java

public static void ReadWords(String FileName){

try{
FileReader f = new FileReader(FileName);

try{
BufferedReader Reader = new BufferedReader(f);
String Line= Reader.readLine();

while (Line != null){

WordArray[NumberWords] = Line.replace("\n","");
NumberWords++;
Line = Reader.readLine();

Reader.close();

}catch(IOException ex){}

© Cambridge University Press & Assessment 2024 Page 4 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(a) }catch(FileNotFoundException e){


System.out.println("File not found");
}

VB.NET

Sub ReadWords(FileName As String)

Try
Dim DataReader As StreamReader = New StreamReader(FileName)
NumberWords = 0
Do Until DataReader.EndOfStream
WordArray(NumberWords) = DataReader.ReadLine()
NumberWords = NumberWords + 1
Loop

DataReader.Close()
Catch ex As Exception
Console.WriteLine("Invalid file")
End Try

End Sub

Python

def ReadWords(FileName):
global WordArray
global NumberWords
File = open(FileName, 'r')
DataRead = File.read().strip()
File.close()
WordArray = DataRead.split()
NumberWords = len(WordArray)

© Cambridge University Press & Assessment 2024 Page 5 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(b) 1 mark each 4


 Outputting message to ask user to enter easy, medium, hard
 Taking input from user
 Conversion of input to filename…
 … calling ReadWords() with correct filename in each case

e.g.

Java

public static void main(String args[]){


NumberWords = 0;
Scanner scanner = new Scanner(System.in);
System.out.println("Easy, medium or hard?");
String Choice = scanner.nextLine();
if(Choice.equals("Easy")){
ReadWords("Easy.txt");
}else if(Choice.equals("medium")){
ReadWords("Medium.txt");
}else{
ReadWords("Hard.txt");
}
}

VB.NET

Sub Main(args As String())


Console.WriteLine("Easy, medium or hard?")
Dim FileName As String
Dim Choice As String = Console.ReadLine().ToLower()
If Choice = "easy" Then
FileName = "Easy.txt"
ElseIf Choice = "medium" Then
FileName = "Medium.txt"
Else

© Cambridge University Press & Assessment 2024 Page 6 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(b) FileName = "Hard.txt"


End If

ReadWords(FileName)
End Sub

Python

WordArray = []
NumberWords = 0
Choice = input("Easy, medium or hard? ").lower()
if Choice == "easy":
File = "Easy.txt"
elif Choice == "medium":
File = "Medium.txt"
else:
File = "Hard.txt"
ReadWords(File)

© Cambridge University Press & Assessment 2024 Page 7 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(c)(i) 1 mark each 6


 Procedure (and end) taking array and number of answers as parameters and outputting the main word and the number
of answers
 Loops until user requests to stop (enters "no") ….
 … takes word as input and compares input to each answer in array but not the main word
 … method of recording answers found e.g. replaces with "" (or appropriate null)
 … outputs if found and not found
 Counts the number of answers found (in loop, second array, any method)

e.g.

Java

public static void Play(){


System.out.println(NumberWords);
Scanner scanner = new Scanner(System.in);
String WordChosen = WordArray[0];
System.out.println("The word is " + WordChosen);
System.out.println("There are " + NumberWords + " words that can be made with 3 or more
letters");
WordArray[0] = "";
Boolean Contin = true;
Integer QuantityFound = 0;
String WordInput;
Boolean Found = false; String Answer = "yes";

while(!(Answer.equals("no"))){

System.out.println("Enter your word or no to stop");


Answer = scanner.nextLine();
Found = false;
if(!(Answer.equals("no"))){
for(Integer x = 0; x <= NumberWords; x++){
if(Answer.equals(WordArray[x])){
WordArray[x] = "";

© Cambridge University Press & Assessment 2024 Page 8 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(c)(i) QuantityFound++;
System.out.println("Correct, you have found " + QuantityFound + " words");
Found = true;
}
}
if(Found == false){
System.out.println("Sorry that was incorrect");
}
}

VB.NET

Sub Play()
Dim Word As String = WordArray(0)
Console.WriteLine("The word is: " & Word)
Console.WriteLine("There are " & NumberWords & " words that can be made with 3 or more
letters")
WordArray(0) = ""
Dim Contin As Boolean = True
Dim QuantityFound As Integer = 0
Dim Found As Boolean
Dim Answer As String = "yes"
While Answer <> "no"
Console.WriteLine("Enter your word or no to stop")
Answer = Console.ReadLine().ToLower()

Found = False
If Answer <> "Not" Then
For x = 0 To NumberWords
If Answer = WordArray(x) Then

© Cambridge University Press & Assessment 2024 Page 9 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(c)(i) WordArray(x) = ""


QuantityFound = QuantityFound + 1
Console.WriteLine("Correct, you have found " & QuantityFound & " words")
Found = True
x = NumberWords + 1
End If

Next x
If Found = False Then
Console.WriteLine("Sorry that was incorrect")
End If

End If

End While

End Sub

Python

def Play():
global WordArray
global NumberWords
Word = WordArray[0]
print("The word is: ", Word)
print("There are", NumberWords-1,"words that can be made with 3 or more letters")
WordArray[0] = ""

Answer = "yes"
QuantityFound = 0
while Answer != "no":
Answer = input("Enter your word or no to stop ").lower()
Found = False

© Cambridge University Press & Assessment 2024 Page 10 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(c)(i) if Answer != "no":


for x in range(0, NumberWords):
if Answer == WordArray[x]:

WordArray[x] = ""
QuantityFound = QuantityFound + 1
print("Correct, you have found", QuantityFound, "words")
Found = True
if Found == False:
print("Sorry that was incorrect")

© Cambridge University Press & Assessment 2024 Page 11 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(c)(ii) 1 mark each 3


 Calculates and outputs percentage of answers found (when ‘no’ is entered)
 Method of identifying answers not found (e.g. looping array and skipping null values)…
 … and outputting those answers

e.g.

Java

public static void Play(){


System.out.println(NumberWords);
Scanner scanner = new Scanner(System.in);
String WordChosen = WordArray[0];
System.out.println("The word is " + WordChosen);

System.out.println("There are " + NumberWords + " words that can be made with 3 or
more letters");
WordArray[0] = "";
Boolean Contin = true;
Integer QuantityFound = 0;
String WordInput;
Boolean Found = false;
String Answer = "yes";

while(!(Answer.equals("no"))){
System.out.println("Enter your word or no to stop");
Answer = scanner.nextLine();
Found = false;
if(!(Answer.equals("no"))){
for(Integer x = 0; x <= NumberWords; x++){
if(Answer.equals(WordArray[x])){
WordArray[x] = "";
QuantityFound++;
System.out.println("Correct, you have found " + QuantityFound + "
words");

© Cambridge University Press & Assessment 2024 Page 12 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(c)(ii) Found = true;


}
}
if(Found == false){
System.out.println("Sorry that was incorrect");
}
}

}
double Correct = ((Double.valueOf(QuantityFound) / Double.valueOf(NumberWords)) *
100.0);
System.out.println("You found " + Correct + "%");

if(Correct < 100){

System.out.println("The words you missed are");


for(Integer x = 0; x <= NumberWords; x++){

if(WordArray[x] != ""){
System.out.println(WordArray[x]);
}

VB.NET

Sub Play()
Dim Word As String = WordArray(0)
Console.WriteLine("The word is: " & Word)
Console.WriteLine("There are " & NumberWords & " words that can be made with 3 or more
letters")

© Cambridge University Press & Assessment 2024 Page 13 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(c)(ii) WordArray(0) = ""


Dim Contin As Boolean = True
Dim QuantityFound As Integer = 0
Dim Found As Boolean
Dim Answer As String = "yes"
While Answer <> "no"
Console.WriteLine("Enter your word or no to stop")
Answer = Console.ReadLine().ToLower()

Found = False
If Answer <> "Not" Then
For x = 0 To NumberWords
If Answer = WordArray(x) Then

WordArray(x) = ""
QuantityFound = QuantityFound + 1
Console.WriteLine("Correct, you have found " & QuantityFound & " words")
Found = True
x = NumberWords + 1
End If

Next x
If Found = False Then
Console.WriteLine("Sorry that was incorrect") End If
End If

End While

Dim Correct As Double


Correct = (QuantityFound / NumberWords) * 100
Console.WriteLine("You found " & Correct & "%")
If Correct < 100 Then
Console.WriteLine("The words you missed are ")
For x = 0 To NumberWords
If WordArray(x) <> "" Then

© Cambridge University Press & Assessment 2024 Page 14 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(c)(ii) Console.WriteLine(WordArray(x))
End If
Next x
End If
End Sub

Python

def Play():
global WordArray
global NumberWords
Word = WordArray[0]
print("The word is: ", Word)
print("There are", NumberWords-1,"words that can be made with 3 or more letters")
WordArray[0] = ""
Answer = "yes"
QuantityFound = 0

while Answer != "no":


Answer = input("Enter your word or no to stop ").lower()
Found = False
if Answer != "no":
for x in range(0, NumberWords):
if Answer == WordArray[x]:

WordArray[x] = ""
QuantityFound = QuantityFound + 1
print("Correct, you have found", QuantityFound, "words")
Found = True
if Found == False:
print("Sorry that was incorrect")
Correct = (QuantityFound / (NumberWords-1)) * 100
print("You found", Correct,"%")

© Cambridge University Press & Assessment 2024 Page 15 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(c)(ii) if Correct < 100:


print("The words you missed are")
for x in range(0, NumberWords-1):
if WordArray[x] != "":
print(WordArray[x])

© Cambridge University Press & Assessment 2024 Page 16 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(d)(i) 1 mark for: 1


 Calling Play() with array and number of answers after all read in from file

e.g.

Java

public static void ReadWords(String FileName){

try{
FileReader f = new FileReader(FileName);

try{

BufferedReader Reader = new BufferedReader(f);


String Line= Reader.readLine();

while (Line != null){

WordArray[NumberWords] = Line.replace("\n","");
NumberWords++;
Line = Reader.readLine();

Reader.close();

Play();

}catch(IOException ex){}

}catch(FileNotFoundException e){
System.out.println("File not found");
}
}

© Cambridge University Press & Assessment 2024 Page 17 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(d)(i) VB.NET

Sub ReadWords(FileName As String)

Try
Dim DataReader As StreamReader = New StreamReader(FileName)
NumberWords = 0
Do Until DataReader.EndOfStream
WordArray(NumberWords) = DataReader.ReadLine()
NumberWords = NumberWords + 1
Loop

DataReader.Close()
Play()
Catch ex As Exception
Console.WriteLine("Invalid file")
End Try
End Sub

Python

def ReadWords(FileName):
global WordArray
global NumberWords
File = open(FileName, 'r')
DataRead = File.read().strip()
File.close()
WordArray = DataRead.split()
NumberWords = len(WordArray)
Play()

© Cambridge University Press & Assessment 2024 Page 18 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(d)(ii) 1 mark for screenshot showing the inputs "easy", "she", "out", "no" e.g. 1

© Cambridge University Press & Assessment 2024 Page 19 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(d)(iii) 1 mark for screenshot showing the inputs ‘hard’, ‘fine’, ‘fined’, ‘idea’, ‘no’ e.g. 1

© Cambridge University Press & Assessment 2024 Page 20 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a)(i) 1 mark each to max 4 4


 Class declaration (and end where appropriate) with identifier Node
 LeftPointer, Data and RightPointer, integer
 Constructor taking 1 parameter (within class) …
 … assigning parameter to Data initialising LeftPointer and RightPointer to –1

e.g.

Java

public class Node{


private Integer LeftPointer;
private Integer Data;
private Integer RightPointer;

public Node(Integer PData){


LeftPointer = -1;
Data = PData;
RightPointer = -1;
}
}

VB.NET

Class Node
Private LeftPointer As Integer
Private Data As Integer
Private RightPointer As Integer
Sub New(PData)
LeftPointer = -1
Data = PData
RightPointer = -1
End Sub
End Class

© Cambridge University Press & Assessment 2024 Page 21 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a)(i) Python

class Node():
def init (self, PData):
self. LeftPointer = -1 #int
self. Data = PData #int
self. RightPointer = -1 #int

© Cambridge University Press & Assessment 2024 Page 22 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a)(ii) 1 mark each 3


 1 get method with no parameter…
 …returning correct attribute
 Remaining 2 correct (FT minor errors)

e.g.

Java

public Integer GetLeft(){


return LeftPointer;
}
public Integer GetRight(){
return RightPointer;
}
public Integer GetData(){
return Data;
}

VB.NET

Function GetLeft()
Return LeftPointer
End Function
Function GetRight()
Return RightPointer
End Function
Function GetData()
Return Data
End Function

Python

def GetLeft(self):
return self. LeftPointer

© Cambridge University Press & Assessment 2024 Page 23 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a)(ii) def GetRight(self):


return self. RightPointer
def GetData(self):
return self. Data

© Cambridge University Press & Assessment 2024 Page 24 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a)(iii) 1 mark each 3


 1 set method with parameter …
 … assigning to attribute
 Remaining 2 correct (FT minor errors)

e.g.

Java

public void SetLeft(Integer NewLeft){


LeftPointer = NewLeft;
}
public void SetRight(Integer NewRight){
RightPointer = NewRight;
}
public void SetData(Integer NewData){
Data = NewData;
}

VB.NET

Sub SetLeft(NewLeft)
LeftPointer = NewLeft
End Sub
Sub SetRight(NewRight)
RightPointer = NewRight
End Sub
Sub SetData(NewData)
Data = NewData
End Sub

Python

def SetLeft(self, NewLeft):


self. LeftPointer = NewLeft
def SetRight(self, NewRight):

© Cambridge University Press & Assessment 2024 Page 25 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a)(iii) self. RightPointer = NewRight


def SetData(self, NewData):
self. Data = NewData

© Cambridge University Press & Assessment 2024 Page 26 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(b)(i) 1 mark each 4


 Class header (and end)
 Private array Tree of type Node with 20 elements, private FirstNode and private NumberNodes
 Constructor assigns –1 to FirstNode and 0 to NumberNodes
 … initialises all Tree (20) elements to Node object with data value –1

e.g.

Java

class TreeClass{

private static Node[] Tree = new Node[20];


private static Integer FirstNode;
private static Integer NumberNodes;

public TreeClass(){
FirstNode = -1;
NumberNodes = 0;
Integer MinusOne = -1;
for(Integer x = 0; x < 20; x++){
Tree[x] = new Node(MinusOne);
}
}
}

VB.NET

Class TreeClass
Private Tree(20) As Node
Private FirstNode As Integer
Private NumberNodes As Integer

Sub New()
FirstNode = -1
NumberNodes = 0

© Cambridge University Press & Assessment 2024 Page 27 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(b)(i) For x = 0 To 19
Tree(x) = New Node(-1)
Next
End Sub
End Class

Python

class TreeClass():

def init (self):


self. Tree = [] #type node 20 spaces
self. FirstNode = -1 #int
self. NumberNodes = 0 #int
for x in range(20):
self. Tree.append(Node(-1))

© Cambridge University Press & Assessment 2024 Page 28 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(b)(ii) 1 mark each: 6


 Method header and end, taking node as parameter and checking if empty and inserting in first position, updating
FirstNode
 … otherwise inserting node in tree
 Accessing first node and comparing data …
 … checking whether to go left or right …
 … repeatedly until data found
 Updating left and right pointer for parent node

e.g.

Java

public void InsertNode(Node NewNode){


Integer NodeAccess;
Integer Previous = -1;
String Direction;

if(NumberNodes == 0){

Tree[0] = NewNode;
FirstNode = 0;
NumberNodes++;
}else{

Tree[NumberNodes] = NewNode;
NodeAccess = FirstNode;
Direction = "";
System.out.println(Tree[0].GetData());
while(NodeAccess != -1){
Previous = NodeAccess;

if(NewNode.GetData() < Tree[NodeAccess].GetData()){


NodeAccess = Tree[NodeAccess].GetLeft();
Direction = "left";

© Cambridge University Press & Assessment 2024 Page 29 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(b)(ii) }else if(NewNode.GetData() > Tree[NodeAccess].GetData()){


NodeAccess = Tree[NodeAccess].GetRight();
Direction = "right";
}

}
if(Direction.equals("left")){
Tree[Previous].SetLeft(NumberNodes);
}else{
Tree[Previous].SetRight(NumberNodes);
}
NumberNodes++;
}
}

VB.NET

Sub InsertNode(NewNode)
Dim NodeAccess As Integer
Dim Direction As String
Dim Previous As Integer

If NumberNodes = 0 Then
Tree(0) = NewNode
FirstNode = 0
NumberNodes += 1
Else
Tree(NumberNodes) = NewNode
NodeAccess = FirstNode
Direction = ""

While NodeAccess <> -1


Previous = NodeAccess

© Cambridge University Press & Assessment 2024 Page 30 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(b)(ii) If NewNode.GetData() < Tree(NodeAccess).GetData() Then


NodeAccess = Tree(NodeAccess).GetLeft()
Direction = "left"
ElseIf NewNode.GetData() > Tree(NodeAccess).GetData() Then
NodeAccess = Tree(NodeAccess).GetRight()
Direction = "right"
End If
End While

If Direction = "left" Then


Tree(Previous).SetLeft(NumberNodes)
Else
Tree(Previous).SetRight(NumberNodes)
End If
NumberNodes += 1
End If
End Sub

Python

def InsertNode(self, NewNode):

if(self. NumberNodes == 0):

self. Tree[0] = NewNode self. FirstNode = 0


self. NumberNodes = self. NumberNodes + 1
else:
self. Tree[self. NumberNodes] = NewNode

NodeAccess = self. FirstNode


Direction = ""

while(NodeAccess != -1):
Previous = NodeAccess
if NewNode.GetData() < self. Tree[NodeAccess].GetData():

© Cambridge University Press & Assessment 2024 Page 31 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(b)(ii) NodeAccess = self. Tree[NodeAccess].GetLeft()


Direction = "left"
elif NewNode.GetData() > self. Tree[NodeAccess].GetData():

NodeAccess = self. Tree[NodeAccess].GetRight()


Direction = "right"

if(Direction == "left"):

self. Tree[Previous].SetLeft(self. NumberNodes)


else:
self. Tree[Previous].SetRight(self. NumberNodes)
self. NumberNodes = self. NumberNodes + 1

© Cambridge University Press & Assessment 2024 Page 32 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(b)(iii) 1 mark each 4


 Procedure header (and end) with no parameter and if no nodes output ‘No nodes’
 (otherwise) Loop from index 0 to NumberNodes (or equivalent) …
 … Outputting LeftPointer, Data then RightPointer
 … using get methods

e.g.

Java

public void OutputTree(){


if(NumberNodes == 0){
System.out.println("No nodes");
}else{
for(Integer x = 0; x < NumberNodes; x++){
System.out.println(Tree[x].GetLeft() + " " + Tree[x].GetData() + " " +
Tree[x].GetRight());

}
}
}

VB.NET

Sub OutputTree()
If NumberNodes = 0 Then
Console.WriteLine("No nodes")
Else
For x = 0 To NumberNodes - 1
Console.WriteLine(Tree(x).GetLeft() & " " & Tree(x).GetData() & " " &
Tree(x).GetRight())
Next
End If
End Sub

© Cambridge University Press & Assessment 2024 Page 33 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(b)(iii) Python

def OutputTree(self):
if self. NumberNodes == 0:
print("No nodes")
else:
for x in range(0, self. NumberNodes):
print(self. Tree[x].GetLeft(), " ", self. Tree[x].GetData(), " ",self.
Tree[x].GetRight())

2(c)(i) 1 mark for 1


 Instance of TreeClass created with identifier TheTree

e.g.

Java

public static void main(String args[]){


TreeClass TheTree = new TreeClass();
}

VB.NET

Sub Main(args As String())


Dim TheTree As TreeClass = New TreeClass()
End Sub

Python

TheTree = TreeClass()

© Cambridge University Press & Assessment 2024 Page 34 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(c)(ii) 1 mark each 4


 Creating one node with one correct value (e.g. 10)
 Calling InsertNode for TheTree with each new Node
 All nodes correctly assigned in order
 Calling OutputTree

e.g.
Java
public static void main(String args[]){
TreeClass TheTree = new TreeClass();
TheTree.InsertNode(new Node(10));
TheTree.InsertNode(new Node(11));
TheTree.InsertNode(new Node(5));
TheTree.InsertNode(new Node(1));
TheTree.InsertNode(new Node(20));
TheTree.InsertNode(new Node(7));
TheTree.InsertNode(new Node(15));
TheTree.OutputTree();
}

VB.NET
Sub Main(args As String())
Dim TheTree As TreeClass = New TreeClass()
TheTree.InsertNode(New Node(10))
TheTree.InsertNode(New Node(11))
TheTree.InsertNode(New Node(5))
TheTree.InsertNode(New Node(1))
TheTree.InsertNode(New Node(20))
TheTree.InsertNode(New Node(7))
TheTree.InsertNode(New Node(15))
TheTree.OutputTree()
End Sub

© Cambridge University Press & Assessment 2024 Page 35 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(c)(ii) Python

TheTree = TreeClass()
TheTree.InsertNode(Node(10))
TheTree.InsertNode(Node(11))
TheTree.InsertNode(Node(5))
TheTree.InsertNode(Node(1))
TheTree.InsertNode(Node(20))
TheTree.InsertNode(Node(7))
TheTree.InsertNode(Node(15))
TheTree.OutputTree()

2(c)(iii) 1 mark for correct output e.g. 1

© Cambridge University Press & Assessment 2024 Page 36 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(a) 1 mark each 1


 NumberArray declared (in main) with the 7 correct values in order (integer) 100 85 644 22 15 8 1

e.g.

Java

public static void main(String args[]){


Integer[] NumberArray = new Integer[7];
NumberArray[0] = 100;
NumberArray[1] = 85;
NumberArray[2] = 644;
NumberArray[3] = 22;
NumberArray[4] = 15;
NumberArray[5] = 8;
NumberArray[6] = 1;
}

VB.NET

Sub Main(args As String())


Dim NumberArray(7) As Integer
NumberArray(0) = 100
NumberArray(1) = 85
NumberArray(2) = 644
NumberArray(3) = 22
NumberArray(4) = 15
NumberArray(5) = 8
NumberArray(6) = 1
EndSub

Python

NumberArray = [100, 85, 644, 22, 15, 8, 1]

© Cambridge University Press & Assessment 2024 Page 37 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(b)(i) 1 mark each 4


 Recursive function written with recursive call
 Correct base case and return
 Correct while loop control and internal
 All correct and structure followed

e.g.

Java
public static Integer[] RecursiveInsertion(Integer[] IntegerArray, Integer NumberElements){
Integer LastItem;
Integer CheckItem;

if(NumberElements <= 1){


return IntegerArray;
}else{
RecursiveInsertion(IntegerArray, NumberElements - 1);
LastItem = IntegerArray[NumberElements - 1];
CheckItem = NumberElements - 2;
}
Boolean LoopAgain = true;
if(CheckItem < 0){
LoopAgain = false;
}else if(IntegerArray[CheckItem] < LastItem){
LoopAgain = false;
}

while(LoopAgain){
IntegerArray[CheckItem + 1] = IntegerArray[CheckItem];
CheckItem = CheckItem - 1;
if(CheckItem < 0){
LoopAgain = false;

© Cambridge University Press & Assessment 2024 Page 38 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(b)(i) }else if(IntegerArray[CheckItem] <= LastItem){


LoopAgain = false;
}
}
IntegerArray[CheckItem + 1] = LastItem;
return IntegerArray;
}

VB.NET

Function RecursiveInsertion(IntegerArray, NumberElements)


Dim LastItem, CheckItem As Integer
If NumberElements <= 1 Then
Return IntegerArray
Else
RecursiveInsertion(IntegerArray, NumberElements - 1)
LastItem = IntegerArray(NumberElements - 1)
CheckItem = NumberElements - 2
End If

Dim LoopAgain As Boolean = True


If CheckItem < 0 Then
LoopAgain = False
ElseIf IntegerArray(CheckItem) <= LastItem Then
LoopAgain = False
End If

While LoopAgain

IntegerArray(CheckItem + 1) = IntegerArray(CheckItem)
CheckItem = CheckItem - 1

If CheckItem < 0 Then


LoopAgain = False
ElseIf IntegerArray(CheckItem) <= LastItem Then

© Cambridge University Press & Assessment 2024 Page 39 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(b)(i) LoopAgain = False


End If
End While

IntegerArray(CheckItem + 1) = LastItem
Return IntegerArray

End Function

Python

def RecursiveInsertion(IntegerArray, NumberElements):

if NumberElements <= 1:
return IntegerArray

RecursiveInsertion(IntegerArray,NumberElements - 1)
LastItem = IntegerArray[NumberElements - 1]
CheckItem = NumberElements - 2

LoopAgain = True
if CheckItem < 0:
LoopAgain = False
elif IntegerArray[CheckItem] <= LastItem:
LoopAgain = False

while (LoopAgain):
IntegerArray[CheckItem + 1] = IntegerArray[CheckItem]
CheckItem = CheckItem - 1

if CheckItem < 0:
LoopAgain = False
elif IntegerArray[CheckItem] <= LastItem:
LoopAgain = False

IntegerArray[CheckItem + 1] = LastItem return IntegerArray

© Cambridge University Press & Assessment 2024 Page 40 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(b)(ii) 1 mark each 2


 Calling RecursiveInsertion() with array and number of elements (7 or length)
 Outputting ‘recursive’ and then each element in returned array

e.g.

Java

Integer[] SortedArray = new Integer[7];


SortedArray = RecursiveInsertion(NumberArray, 7);
System.out.println("Recursive");
for(Integer x = 0; x < 7; x++){
System.out.println(SortedArray[x]);
}

VB.NET

SortedArray = RecursiveInsertion(NumberArray, 7)
Console.WriteLine("Recursive")
For x = 0 To 6
Console.WriteLine(SortedArray(x))
Next x

Python

SortedArray = RecursiveInsertion(NumberArray, len(NumberArray))


print("Recursive", SortedArray)

© Cambridge University Press & Assessment 2024 Page 41 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(b)(iii) 1 mark for screenshot with: 1


Recursive
1
8
15
22
85
100
644

© Cambridge University Press & Assessment 2024 Page 42 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(c)(i) 1 mark each 4


 Insertion algorithm written with correct identifier – no recursion
 External loop while there are still elements left (e.g. NumberElements > 0)
 Internal loop and selection accurate
 Nothing additional added / logic changed

e.g.

Java

public static Integer[] IterativeInsertion(Integer[] IntegerArray, Integer NumberElements){


Integer LastItem;
Integer CheckItem;
while(NumberElements > 0){
LastItem = IntegerArray[NumberElements - 1];
CheckItem = NumberElements - 2;

Boolean LoopAgain = true;


if(CheckItem < 0){
LoopAgain = false;
}else if(IntegerArray[CheckItem] < LastItem){
LoopAgain = false;
}

while(LoopAgain){
IntegerArray[CheckItem + 1] = IntegerArray[CheckItem];
CheckItem = CheckItem - 1;
if(CheckItem < 0){
LoopAgain = false;
}else if(IntegerArray[CheckItem] <= LastItem){
LoopAgain = false;
}
}

© Cambridge University Press & Assessment 2024 Page 43 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(c)(i) IntegerArray[CheckItem + 1] = LastItem;


NumberElements = NumberElements - 1;
}
return IntegerArray;
}

VB.NET
Function IterativeInsertion(IntegerArray, NumberElements)
Dim LastItem, CheckItem As Integer
While NumberElements > 0
LastItem = IntegerArray(NumberElements - 1)
CheckItem = NumberElements - 2
Dim LoopAgain As Boolean = True
If CheckItem < 0 Then
LoopAgain = False
ElseIf IntegerArray(CheckItem) <= LastItem Then
LoopAgain = False
End If
While LoopAgain
IntegerArray(CheckItem + 1) = IntegerArray(CheckItem)
CheckItem = CheckItem - 1
If CheckItem < 0 Then
LoopAgain = False
ElseIf IntegerArray(CheckItem) <= LastItem Then
LoopAgain = False
End If
End While
IntegerArray(CheckItem + 1) = LastItem
NumberElements = NumberElements - 1

End While
Return IntegerArray
End Function

© Cambridge University Press & Assessment 2024 Page 44 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(c)(i) Python

def IterativeInsertion(IntegerArray, NumberElements):


while NumberElements > 0:
LastItem = IntegerArray[NumberElements - 1]
CheckItem = NumberElements - 2
LoopAgain = True
if CheckItem < 0:
LoopAgain = False
elif IntegerArray[CheckItem] <= LastItem:
LoopAgain = False
while(LoopAgain):
IntegerArray[CheckItem + 1] = IntegerArray[CheckItem]
CheckItem = CheckItem - 1
if CheckItem < 0:
LoopAgain = False
elif IntegerArray[CheckItem] <= LastItem:
LoopAgain = False

IntegerArray[CheckItem + 1] = LastItem
NumberElements = NumberElements - 1
return IntegerArray

© Cambridge University Press & Assessment 2024 Page 45 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(c)(ii) 1 mark each 1


 Calling IterativeInsertion() with original unsorted array and outputting ‘iterative’ and the content of the returned
array

e.g.

Java

Integer[] Sorted2Array = new Integer[7];


Sorted2Array = IterativeInsertion(NumberArray, 7);
System.out.println("iterative");
for(Integer x = 0; x < 7; x++){
System.out.println(Sorted2Array[x]);
}

VB.NET

Sorted2Array = IterativeInsertion(NumberArray, 7)
Console.WriteLine("iterative")
For x = 0 To 6
Console.WriteLine(Sorted2Array(x))
Next x

Python

Sorted2Array = IterativeInsertion(NumberArray, len(NumberArray))


print("iterative", Sorted2Array)

3(c)(iii) 1 mark for Recursive 1


1 8 15 22 85 100 644

Iterative
1 8 15 22 85 100 644

© Cambridge University Press & Assessment 2024 Page 46 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(d)(i) 1 mark each to max 6 6


 Recursive function BinarySearch taking the 4 indicated parameters
 Suitable base case (e.g. First > Last) …
 … returning –1
 Calculating middle element
 Comparing ToFind with middle and returning Middle if found
 If ToFind less than middle, recursive call with Last as Middle – 1
 If ToFind more than middle, recursive call with First as Middle + 1

e.g.

Java
public static Integer BinarySearch(Integer[] IntegerArray, Integer First, Integer Last,
Integer ToFind){
Integer Middle;
if(First > Last){;
return -1;
}else{
Middle = (Last + First) / 2;

if(IntegerArray[Middle].equals(ToFind)){
return Middle;
}else if(IntegerArray[Middle] > ToFind){
return BinarySearch(IntegerArray, First, Middle - 1, ToFind);
}else{
return BinarySearch(IntegerArray, Middle + 1, Last, ToFind);
}
}
}

VB.NET
Function BinarySearch(IntegerArray, First, Last, ToFind)
Dim Middle As Integer
If First > Last Then

© Cambridge University Press & Assessment 2024 Page 47 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(d)(i) Return -1
Else
Middle = (Last + First) \ 2
If IntegerArray(Middle) = ToFind Then

Return Middle
ElseIf IntegerArray(Middle) > ToFind Then
Return BinarySearch(IntegerArray, First, Middle - 1, ToFind)
Else
Return BinarySearch(IntegerArray, Middle + 1, Last, ToFind)
End If
End If
End Function

Python

def BinarySearch(IntegerArray, First, Last, ToFind):

if First > Last:


return -1
else:
Middle = int((Last + First) / 2)

if IntegerArray[Middle] == ToFind:
return Middle

elif IntegerArray[Middle] > ToFind:


return BinarySearch(IntegerArray, First, Middle - 1, ToFind)

else:
return BinarySearch(IntegerArray, Middle + 1, Last, ToFind)

© Cambridge University Press & Assessment 2024 Page 48 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(d)(ii) 1 mark each 2


 Calling BinarySearch function with sorted array, 0, 6/len(array)–1, 644 as parameters
 Checking return value and outputting ‘Not found’ if –1 and index otherwise

e.g.

Java

Position = BinarySearch(Sorted2Array, 0, 6, 644);


if(Position == -1){
System.out.println("Not found");
}else{
System.out.println(Position);
}

VB.NET

Position = BinarySearch(Sorted2Array, 0, 6, 644)


If Position = -1 Then
Console.WriteLine("Not found")
Else
Console.WriteLine(Position)
End If

Python

Position = BinarySearch(Sorted2Array, 0, len(NumberArray)-1, 644)


if Position == -1:
print("Not found")
else:
print(Position)

© Cambridge University Press & Assessment 2024 Page 49 of 50


9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(d)(iii) 1 mark for screenshot showing found in index 6 e.g. 1

© Cambridge University Press & Assessment 2024 Page 50 of 50


Cambridge International AS & A Level

COMPUTER SCIENCE 9618/43


Paper 4 Practical May/June 2024
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge International will not enter into discussions about these mark schemes.

Cambridge International is publishing the mark schemes for the May/June 2024 series for most
Cambridge IGCSE, Cambridge International A and AS Level and Cambridge Pre-U components, and some
Cambridge O Level components.

This document consists of 38 printed pages.

© Cambridge University Press & Assessment 2024 [Turn over


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Generic Marking Principles

These general marking principles must be applied by all examiners when marking candidate answers. They should be applied alongside the
specific content of the mark scheme or generic level descriptions for a question. Each question paper and mark scheme will also comply with these
marking principles.

GENERIC MARKING PRINCIPLE 1:

Marks must be awarded in line with:

 the specific content of the mark scheme or the generic level descriptors for the question
 the specific skills defined in the mark scheme or in the generic level descriptors for the question
 the standard of response required by a candidate as exemplified by the standardisation scripts.

GENERIC MARKING PRINCIPLE 2:

Marks awarded are always whole marks (not half marks, or other fractions).

GENERIC MARKING PRINCIPLE 3:

Marks must be awarded positively:

 marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit is given for valid answers which go beyond
the scope of the syllabus and mark scheme, referring to your Team Leader as appropriate
 marks are awarded when candidates clearly demonstrate what they know and can do
 marks are not deducted for errors
 marks are not deducted for omissions
 answers should only be judged on the quality of spelling, punctuation and grammar when these features are specifically assessed by the
question as indicated by the mark scheme. The meaning, however, should be unambiguous.

GENERIC MARKING PRINCIPLE 4:

Rules must be applied consistently, e.g. in situations where candidates have not followed instructions or in the application of generic level
descriptors.

© Cambridge University Press & Assessment 2024 Page 2 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
GENERIC MARKING PRINCIPLE 5:

Marks should be awarded using the full range of marks defined in the mark scheme for the question (however; the use of the full mark range may
be limited according to the quality of the candidate responses seen).

GENERIC MARKING PRINCIPLE 6:

Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should not be awarded with grade thresholds or
grade descriptors in mind.

© Cambridge University Press & Assessment 2024 Page 3 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(a) 1 mark for: 1


 Declaration of (global) array with identifier DataStored (Integer and 20 spaces)
and NumberItems (Integer)
e.g.
Java
public static Integer[] DataStored = new Integer[20];
public static Integer NumberItems= 0;

VB.NET
Dim DataStored(19) As Integer
Dim NumberStored As Integer = 0

Python
global DataStored #integer
global NumberItems #Integer 20 items

© Cambridge University Press & Assessment 2024 Page 4 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(b) 1 mark each 5


 Procedure heading (and close where appropriate) with no parameter.
 Prompt/output of suitable message to request the input of the quantity of numbers
and reading in quantity of numbers and storing/using …
 … each input in next space in DataStored
e.g.
Java
public static void Initialise(){
Scanner scanner = new Scanner(System.in);
Integer Quantity = 0;
do{
System.out.println("How many numbers will you enter up to 20?");
Quantity = Integer.parseInt(scanner.nextLine());
}while(Quantity <= 0 || Quantity > 20);
for(Integer X = 0; X < Quantity; X++){
System.out.println("Enter number");
DataStored[NumberItems] = Integer.parseInt(scanner.nextLine());
NumberItems++;

VB.NET
Sub Initialise()
Console.WriteLine("How many numbers will you enter?")
Dim Quantity As Integer
Do
Quantity = Console.ReadLine()
Loop Until (Quantity > 0 And Quantity < 21)
For Count = 0 To Quantity - 1
Console.WriteLine("Enter number")
DataStored(NumberStored) = Console.ReadLine()
NumberStored += 1
Next
End Sub

© Cambridge University Press & Assessment 2024 Page 5 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(b) Python
def Initialise():
global DataStored
global NumberItems
Valid = False
while(Valid == False):
NumberItems = int(input("How many numbers will you enter?")) #loop until < 20
if NumberItems > 0 and NumberItems< 21:
Valid = True
for Count in range(0, NumberItems):
DataStored.append(int(input("Enter number")))

1(c)(i) 1 mark each: 2


 Storing 0 in NumberItems and then calling Initialise()
 Outputting all contents of array DataStored
e.g.
Java
public static Integer NumberItems= 0;
Initialise();
for(Integer X = 0; X < NumberItems; X++){
System.out.println(DataStored[X]);

VB.NET
NumberItems = 0
Initialise()
For X = 0 To NumberItems - 1
Console.WriteLine(DataStored(X))
Next

Python
NumberItems = 0
Initialise()
print(DataStored)

© Cambridge University Press & Assessment 2024 Page 6 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(c)(ii) 1 mark each 2


 Output showing quantity entered twice (30 and 5) with first being invalid
 Array output 3 9 4 1 2
e.g.

© Cambridge University Press & Assessment 2024 Page 7 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(d)(i) 1 mark each 4


 Procedure header (and end where appropriate)
and looping through each array element
 Working inner loop …
 …comparison of elements…
 …swapping of elements
e.g.
Java
public static void BubbleSort(){
Integer Temp = 0;
for(Integer Count = 0; Count < NumberItems; Count++){
for(Integer Count2 = 0; Count2 < NumberItems - 1; Count2++){
if(DataStored[Count2] > DataStored[Count]){
Temp = DataStored[Count2];
DataStored[Count2] = DataStored[Count];
DataStored[Count] = Temp;
}
}
}
}
VB.NET
Sub BubbleSort()
Dim Temp As Integer
For Count = 0 To NumberStored - 1
For Count2 = 0 To NumberStored - 2
If (DataStored(Count2) > DataStored(Count)) Then
Temp = DataStored(Count) DataStored(Count) = DataStored(Count2)
DataStored(Count2) = Temp
End If
Next
Next
End Sub

© Cambridge University Press & Assessment 2024 Page 8 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(d)(i) Python
def BubbleSort():
global DataStored
global NumberItems
for Count in range(0, NumberItems):
for Count2 in range(0, NumberItems-1):
if DataStored[Count2] > DataStored[Count]:
DataStored[Count2], DataStored[Count] = DataStored[Count],
DataStored[Count2]

1(d)(ii) 1 mark for calling BubbleSort() and outputting array contents after 1
e.g.
VB.NET
BubbleSort()
For X = 0 To NumberStored - 1
Console.WriteLine(DataStored(X))
Next

e.g. Java
BubbleSort();
for(Integer X = 0; X < NumberItems; X++){
System.out.println(DataStored[X]);
}
e.g. Python
BubbleSort()
print(DataStored)

1(d)(iii) 1 mark for screenshot showing the inputs and the values in the correct order 1
e.g.

© Cambridge University Press & Assessment 2024 Page 9 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(e)(i) 1 mark each 6


 Function header BinarySearch taking DataToFind as a parameter
 Calculating the mid value (First + Last) \ 2 or equivalent inside loop
 Checking if the data at mid is the parameter and returning mid inside loop
 If DataToFind < mid, updating Last/Upper with mid – 1 inside loop
 If DataToFind > mid, updating First/Lower with mid + 1 inside loop
 Returning -1 when not found and a suitable loop with end criteria
e.g.
Java
public static Integer BinarySearch(Integer DataToFind){
Integer MidValue = 0;
Integer First = 0;
Integer Last = NumberItems;
while (First <= Last){
MidValue = (First + Last) / 2;
if(DataToFind == DataStored[MidValue]){
return MidValue;
}
if(DataToFind < DataStored[MidValue]){
Last = MidValue - 1;
}else{
First = MidValue + 1;
}
}
return -1;
}

© Cambridge University Press & Assessment 2024 Page 10 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(e)(i) VB.NET
Function BinarySearch(DataToFind)
Dim First As Integer = 0
Dim Last As Integer = NumberItems
Dim MidValue As Integer
While (First <= Last)
MidValue = (First + Last) / 2
If DataToFind = DataStored(MidValue) Then
Return MidValue
End If
If DataToFind < DataStored(MidValue) Then
Last = MidValue - 1
Else
First = MidValue + 1
End If
End While
Return -1
End Function

Python
def BinarySearch(DataToFind):
global DataStored
global NumberItems
First = 0
Last= NumberItems
while(First <= Last):
MidValue = int((First + Last) / 2)

if DataToFind == DataStored[MidValue]:
return MidValue
if DataToFind < DataStored[MidValue]:
Last = MidValue - 1
else:
First = MidValue + 1

return -1

© Cambridge University Press & Assessment 2024 Page 11 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(e)(ii) 1 mark each: 3


 Taking number as input
… calling BinarySearch with input
 Outputting value returned
e.g.
Java
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a number to find");
Integer Search = Integer.parseInt(scanner.nextLine());
System.out.println(BinarySearch(Search));

VB.NET
Console.WriteLine("Enter a number to find")
Dim Search As Integer = Console.ReadLine()
Console.WriteLine(BinarySearch(Search))

Python
Search = int(input("Enter a number to find"))
print(BinarySearch(Search))

© Cambridge University Press & Assessment 2024 Page 12 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

1(e)(iii) 1 mark for each test 2


e.g.
Test 1 – Accept found in index 16

Test 2

© Cambridge University Press & Assessment 2024 Page 13 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a)(i) 1 mark each to max 4 4


 Class Tree declaration (and end where appropriate)
 All 5 attributes declared as private with correct identifiers and data types
 Constructor header (and end) taking 5 parameters
 Constructor assigns parameters to attributes
e.g.
Java
class Tree{
private String TreeName;
private Integer HeightGrowth;
private Integer MaxWidth;
private Integer MaxHeight;
private String Evergreen;

public Tree(String Name, Integer HGrowth, Integer MaxH, Integer MaxW, String
PEvergreen){
TreeName = Name;
HeightGrowth = HGrowth;
MaxWidth = MaxW;
MaxHeight = MaxH;
Evergreen = PEvergreen;
}}

© Cambridge University Press & Assessment 2024 Page 14 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a)(i) VB.NET
Class Tree
Private TreeName As String
Private HeightGrowth As Integer
Private MaxHeight As Integer
Private MaxWidth As Integer
Private Evergreen As String
Sub New(Name, HGrowth, MaxH, MaxW, PEvergreen)
TreeName = Name
HeightGrowth = HGrowth
MaxHeight = MaxH
MaxWidth = MaxW
Evergreen = PEvergreen
End Sub
End Class

Python
class Tree:
def __init__(self, Name, HGrowth, MaxH, MaxW, PEvergreen):
self.__TreeName = Name
self.__HeightGrowth = HGrowth
self.__MaxHeight = MaxH
self.__MaxWidth = MaxW
self.__Evergreen = PEvergreen

© Cambridge University Press & Assessment 2024 Page 15 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a)(ii) 1 mark each 3


 1 get method with no parameter …
 … returning correct attribute
 Remaining 4 correct
e.g.
Java
public String GetTreeName(){
return TreeName;
}
public Integer GetGrowth(){
return HeightGrowth;
}
public Integer GetMaxWidth(){
return MaxWidth;
}
public Integer GetMaxHeight(){
return MaxHeight;
}
public String GetEvergreen(){
return Evergreen;
}

© Cambridge University Press & Assessment 2024 Page 16 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(a)(ii) VB.NET
Function GetTreeName()
Return TreeName
End Function
Function GetMaxHeight()
Return MaxHeight
End Function
Function GetMaxWIdth()
Return MaxWidth
End Function
Function GetGrowth()
Return HeightGrowth
End Function
Function GetEvergreen()
Return Evergreen
End Function

Python
def GetTreeName(self):
return self.__TreeName
def GetMaxHeight(self):
return self.__MaxHeight
def GetMaxWidth(self):
return self.__MaxWidth
def GetGrowth(self):
return self.__HeightGrowth
def GetEvergreen(self):
return self.__Evergreen

© Cambridge University Press & Assessment 2024 Page 17 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
2(b) 1 mark for: 7
 appropriate use of exception handling, with catch and output
1 mark each to max 6
 Function header (and end where appropriate) and declaration of array (of type Tree with min 9 elements)
 Opening text file Trees.txt to read and closing the file
 Reading each line of text (until EOF, or 9 times)
 Splitting each line into the 5 elements
… casting height growth, max height and max width to integers
… creating a new object of type Tree with the 5 values
… storing each object in the array and returning the array
e.g.
Java
public static Tree[] ReadData(){
String TextFile = "Trees.txt";
String[] TempData = new String[5];
Tree[] TreeData = new Tree[20];
String Line;
try{
FileReader f = new FileReader(TextFile);
BufferedReader Reader = new BufferedReader(f);
for(Integer X = 0; X < 9; X++){
try{
Line = Reader.readLine();
TempData = Line.split(",");
TreeData[X] = new Tree(TempData[0], Integer.parseInt(TempData[1]),
Integer.parseInt(TempData[2]), Integer.parseInt(TempData[3]), TempData[4]);
}catch(IOException ex){}
}
try{
Reader.close();
}catch(IOException ex){}

}catch(FileNotFoundException e){
System.out.println("File not found");
}
return TreeData;
}

© Cambridge University Press & Assessment 2024 Page 18 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(b) VB.NET
Function ReadData()
Dim TreeObjects(10) As Tree
Dim TextFile As String = "Trees.txt"
try
Dim FileReader As New System.IO.StreamReader(TextFile)
Dim TreeData(10) As String
Dim TreeSplit() As String
For Count = 0 To 8
TreeData(Count) = FileReader.ReadLine()

Next Count
FileReader.Close()

For X = 0 To 8

TreeSplit = TreeData(X).Split(",")
TreeObjects(X) = New Tree(TreeSplit(0), Integer.Parse(TreeSplit(1)),
Integer.Parse(TreeSplit(2)), Integer.Parse(TreeSplit(3)), TreeSplit(4))
Next X
Catch ex As Exception
Console.WriteLine ("invalid file")
End Try
Return TreeObjects

End Function

© Cambridge University Press & Assessment 2024 Page 19 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(b) Python
def ReadData():
TreeObjects=[]
try:
File = open("Trees.txt")
TreeData = []
TreeData = File.read().split("\n")
SplitTrees = []
for Item in TreeData:
SplitTrees.append(Item.split(","))
File.close()
for Item in SplitTrees:

TreeObjects.append(Tree(Item[0],int(Item[1]),int(Item[2]),int(Item[3]),Item[4]))
except IOError:
print ("invalid file")
return TreeObjects

© Cambridge University Press & Assessment 2024 Page 20 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(c) 1 mark each 4


 Procedure heading (and end) taking one parameter (of type Tree)
and using get methods to access tree name, height, width, growth
 Outputs all 4 attributes (TreeName, MaxHeight, MaxWidth, GetGrowth)
 Checks if it is evergreen…
… correct messages are output if evergreen and otherwise

e.g.
Java
public static void PrintTrees(Tree TreeItem){
String Final = "does not lose its leaves";
if((TreeItem.GetEvergreen()).compareTo("No") == 0){
Final = "loses its leaves each year";
}
System.out.println(TreeItem.GetTreeName() + " has a maximum height " +
TreeItem.GetMaxHeight() + " a maximum width " + TreeItem.GetMaxWidth() + " and grows " +
TreeItem.GetGrowth() + " cm a year. It " + Final);
}

VB.NET
Sub PrintTrees(Item)
Dim Final As String = "does not lose its leaves"
If (Item.GetEvergreen() = "No") Then
Final = "loses its leaves each year"
End If
Console.WriteLine(Item.GetTreeName() & " has a maximum height " &
Item.GetMaxHeight() & " a maximum width " & Item.GetMaxWidth() & " and grows " &
Item.GetGrowth() & "cm a year. It" & Final)
End Sub

© Cambridge University Press & Assessment 2024 Page 21 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(c) Python
def PrintTrees(Item):

Final = "does not lose its leaves"


if Item.GetEvergreen() == "No":
Final = "loses its leaves each year"
print(Item.GetTreeName(), "has a maximum height", Item.GetMaxHeight(),"a maximum
width",Item.GetMaxWidth(),"and grows", Item.GetGrowth(),"cm a year. It",Final)

2(d)(i)  1 mark each 2


 Calling ReadData() and storing/using return value (as array of type Tree)…
…calling PrintTrees() with first object in returned array as parameter

e.g.
Java
Tree[] TreeData = new Tree[20];
TreeData = ReadData();
PrintTrees(TreeData[0]);

VB.NET
Sub Main(args As String())
Dim TreeObjects(10) As Tree
TreeObjects = ReadData()
PrintTrees(Treeobjects(0))
End Sub

Python
TreeObjects = ReadData()
PrintTrees(TreeObjects[0])

2(d)(ii) Screenshot showing output 1

© Cambridge University Press & Assessment 2024 Page 22 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(e)(i) 1 mark each to max 6 6


 Procedure header (and close) taking array of Tree objects as a parameter
and reading evergreen, max height and max width once as input from the user

 Looping through each array object …


 … comparing each width input >= MaxWidth, height input >= MaxHeight
 … comparing each evergreen input with Evergreen
… when all true (all requirements met) - appending object in new array
 Calling PrintTrees() with each valid object
 Outputting suitable message if no trees appropriate

e.g.
Java
public static void ChooseTree(Tree[] Trees){
Scanner scanner = new Scanner(System.in);
System.out.println("Do you want a tree that loses its leaves (enter lose), or keeps
its leaves (enter keep)") ;
String Evergreen = (scanner.nextLine());
System.out.println("What is the maximum tree height in cm");
Integer MaxHeight = Integer.parseInt(scanner.nextLine());
System.out.println("What is the maximum tree width in cm");
Integer MaxWidth = Integer.parseInt(scanner.nextLine());
Tree[] Options = new Tree[20];
String keep;
Tree Selected;
Boolean Valid = false;
if(((Evergreen.toLowerCase()).compareTo("keep") == 0) ||
((Evergreen.toLowerCase()).compareTo("keep leaves") == 0) ||
((Evergreen.toLowerCase()).compareTo("keeps its leaves") == 0)){
keep = "Yes";
}else{
keep = "No";
}
Integer Counter = 0;
for(Integer X = 0; X < 9; X++){

© Cambridge University Press & Assessment 2024 Page 23 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(e)(i) if((Trees[X].GetMaxHeight() <= MaxHeight) && (Trees[X].GetMaxWidth() <=


MaxWidth) && (keep.compareTo(Trees[X].GetEvergreen())==0)){
Options[Counter] = Trees[X];
PrintTrees(Trees[X]);
Counter = Counter + 1;
}
}
if(Counter == 0){
System.out.println("No suitable trees");
}
}

VB.NET
Sub ChooseTree(Trees)
Console.WriteLine("Do you want a tree that loses its leaves (enter lose), or keeps
its leaves (enter keep)")
Dim Evergreen As String = Console.ReadLine()
Console.WriteLine("What is the maximum tree height in cm")
Dim MaxHeight As Integer = Console.ReadLine()
Console.WriteLine("What is the maximum tree width in cm")
Dim MaxWidth As Integer = Console.ReadLine()
Dim Options(0 To 9) As Tree
Dim keep As String
Dim Valid As Boolean
Dim Selected As Tree
If Evergreen.ToLower() = "keep" Or Evergreen.ToLower() = "keep leaves" Or
Evergreen.ToLower() = "keeps its leaves" Then
keep = "Yes"
Else
keep = "No"

© Cambridge University Press & Assessment 2024 Page 24 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(e)(i) End If
Dim count As Integer = 0
For x = 0 To 8
If Trees(x).GetMaxHeight() <= MaxHeight And Trees(x).GetMaxWidth() <= MaxWidth
And keep = Trees(x).GetEvergreen() Then
Options(count) = Trees(x)
PrintTrees(Trees(x))
count = count + 1
End If
Next x
If count = 0 Then
Console.WriteLine("No suitable trees")
End If
End Sub

Python
def ChooseTree(Trees):
Evergreen = input("Do you want a tree that loses its leaves (enter lose), or keeps its
leaves (enter keep)")
MaxHeight = int(input("What is the maximum tree height in cm"))
MaxWidth = int(input("What is the maximum tree width in cm"))
Options = []
if Evergreen.lower() == "keep" or Evergreen.lower() == "keep leaves" or
Evergreen.lower() == "keeps its leaves":
keep = "Yes"
else:
keep = "No"
for Item in Trees:

if Item.GetMaxHeight() <= MaxHeight and Item.GetMaxWidth() <= MaxWidth and keep ==


Item.GetEvergreen():
Options.append(Item)
PrintTrees(Item)
if len(Options) == 0:
print("No suitable trees")

© Cambridge University Press & Assessment 2024 Page 25 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(e)(ii) 1 mark each to max 2


 Taking tree name and initial height as input
 Finding the tree, calculating and outputting the number of years to get to maximum height
VB.NET
Valid = False
Dim Start As Integer
Dim Years As Single
Dim Choice As String
While Valid = False
Console.WriteLine("Enter the name of the tree you want")
Choice = Console.ReadLine()
For X = 0 To count - 1
If Options(X).GetTreeName() = Choice Then
Valid = True
Selected = Options(X)
Console.WriteLine("Enter the height of the tree you would like to start with in
cm")
Start = Console.ReadLine()
Years = (Selected.GetMaxHeight() - Start) / Selected.GetGrowth()
Console.WriteLine("Your tree should be full height in approximately " & Years &
" years")
End If
Next X
End While

© Cambridge University Press & Assessment 2024 Page 26 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(e)(ii) Java
Integer Start;
Float Height;
Float Growth;
Float Years;
while(Valid == false){
System.out.println("Enter the name of the tree you want");
String Choice = scanner.nextLine();
for(Integer X = 0; X < Counter; X++){
if((Options[X].GetTreeName()).compareTo(Choice)==0){
Valid = true;
Selected = Options[X];
System.out.println("Enter the height of the tree you would like to start
with in cm");
Start = Integer.parseInt(scanner.nextLine());
Height = (Selected.GetMaxHeight()).floatValue();
Growth = (Selected.GetGrowth()).floatValue();
Years = (Height - Start) / Growth;
System.out.println("Your tree should be full height in approximately "+
Years + " years");
}
}
}

Python:
Valid = False
while Valid == False:
Choice = input("Enter the name of the tree you want")
for Item in Options:
if Item.GetTreeName() == Choice:
Valid = True
Selected = Item
Start = int(input("Enter the height of the tree you would like to start with in
cm"))
Years = (Selected.GetMaxHeight() - Start)/Selected.GetGrowth()
print("Your tree should be full height in approximately", Years,"years")

© Cambridge University Press & Assessment 2024 Page 27 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

2(e)(iii) 1 mark each 2


 Screenshot shows the user requirements input (height 400, width 200, evergreen) and outputs the correct trees (Blue
conifer and green conifer)
 Screenshot shows the tree selection input (Blue Conifer with height 100) and outputs the correct result (3 years / 3.75
/ 4 years)

© Cambridge University Press & Assessment 2024 Page 28 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(a) 1 mark each 1


 QueueData as 1D (string) array initialised to 20 null values
and QueueHead initialised to -1, QueueTail initialised to -1
e.g.
Java
class Queue{
public static String[] QueueData = new String[20];
public static Integer QueueHead;
public static Integer QueueTail;
public static void main(String args[]){
for(Integer x = 0; x < 20; x++){
QueueData[x] = "";
}
QueueHead = -1;
QueueTail = -1;
}
}
VB.NET
Dim QueueData(0 To 20) As String
Dim QueueHead As Integer = -1
Dim QueueTail As Integer = -1
Sub Main(args As String())
For x = 0 To 19
QueueData(x) = ""
Next
End Sub

Python
global QueueData
global QueueHead
global QueueTail
QueueData = []
for x in range(0, 20):
QueueData.append("")
QueueHead = -1
QueueTail = -1

© Cambridge University Press & Assessment 2024 Page 29 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(b) 1 mark each 4


 Function header (and end) taking one parameter and returns a Boolean value in all instances
 Checks if queue is full and returns FALSE
 (If not full) Inserts data item to QueueTail + 1
and increments QueueTail
and returns TRUE
 Assigns QueueHead to 0 when first element is entered (this can come from incrementing)
e.g.
Java
public static Boolean Enqueue(String DataToInsert){
if(QueueTail == 19){
return false;
}else if(QueueHead == -1){
QueueHead = 0;
}
QueueTail = QueueTail + 1;
QueueData[QueueTail] = DataToInsert.substring(0,6);
return true;
}
VB.NET
Function Enqueue(ByVal DataToInsert)
If QueueTail = 19 Then
Return False
ElseIf QueueHead = -1 Then
QueueHead = 0
End If
QueueTail = QueueTail + 1
QueueData(QueueTail) = DataToInsert
Return True
End Function

© Cambridge University Press & Assessment 2024 Page 30 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(b) Python
def Enqueue(DataToInsert):
global QueueData
global QueueHead
global QueueTail
if QueueTail == 19:
return False
elif QueueHead == -1:
QueueHead = 0
QueueTail = QueueTail + 1
QueueData.append(DataToInsert)
return True

© Cambridge University Press & Assessment 2024 Page 31 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(c) 1 mark each 3


 Dequeue function header (and end) returning a string in all cases
 Check if queue is empty
and return "false"
 (otherwise) remove value at QueueHead
and increment QueueHead
and return value from array
e.g.
Java
public static String Dequeue(){
if(QueueHead < 0 || QueueHead > 20 || QueueHead > QueueTail){
return "false";
}
QueueHead++;
return QueueData[QueueHead-1];
}
VB.NET
Function Dequeue()
If QueueHead < 0 Or QueueHead > 20 Or QueueHead > QueueTail Then
Return "false"
Else
QueueHead = QueueHead + 1
Return QueueData(QueueHead - 1)
End If
End Function

© Cambridge University Press & Assessment 2024 Page 32 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(c) Python
def Dequeue():
global QueueData
global QueueHead
global QueueTail
if QueueHead < 0 or QueueHead > 20 or QueueHead > QueueTail:
return False
else:
QueueHead = QueueHead + 1

return QueueData[QueueHead-1]

3(d)(i) 1 mark each to max 6 6


 StoreItems header (function/procedure and end where appropriate)
and takes 10 inputsi
 Input is split and first 6 characters used in calculation (as integers) …
 … multiplication by 1 and 3 alternately, adding to total, dividing by 10, rounding down/cast int …
 … comparing check digit to character in position 6
 … including comparison of X for 10

 Calling Enqueue with first 6 characters when valid


 … outputting appropriate message on return (for both inserted and queue full)
 Counts and outputs number of invalid inputs
e.g.
Java
public static void StoreItems(){
Integer Count = 0;
Integer Total = 0;
String Data;
Boolean Result;
Scanner scanner = new Scanner(System.in);
for(Integer X = 0; X < 10; X++){
System.out.println("Enter data");
Data = scanner.nextLine();
Total = Integer.parseInt(Data.substring(0,1)) +

© Cambridge University Press & Assessment 2024 Page 33 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(d)(i) Integer.parseInt(Data.substring(1,2)) * 3 + Integer.parseInt(Data.substring(2,3)) +


Integer.parseInt(Data.substring(3,4)) * 3 + Integer.parseInt(Data.substring(4,5)) +
Integer.parseInt(Data.substring(5,6)) * 3;
Total = Total / 10;
if((Total == 10 && Data.substring(6).compareTo("X")==0)){
Result = Enqueue(Data);
if(Result == true){
System.out.println("Inserted item");
}else{
System.out.println("Queue full");
}
}else if(Total == Integer.parseInt(Data.substring(6,7))){
Result = Enqueue(Data);
if(Result == true){
System.out.println("Inserted item");
}else{
System.out.println("Queue full");
}
}else{
Count = Count + 1;
}
}

System.out.println("There were " + Count + " invalid items");


}

VB.NET
Sub StoreItems()

Dim Count As Integer = 0


Dim Total As Integer = 0
Dim Data As String
Dim Result As Boolean
For X = 0 To 9
Console.WriteLine("Enter data")
Data = Console.ReadLine()

© Cambridge University Press & Assessment 2024 Page 34 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(d)(i) Total = Integer.Parse(Data.Substring(0, 1)) + Integer.Parse(Data.Substring(1, 1)) *


3 + Integer.Parse(Data.Substring(2, 1)) + Integer.Parse(Data.Substring(3, 1)) * 3 +
Integer.Parse(Data.Substring(4, 1)) + Integer.Parse(Data.Substring(5, 1)) * 3
Total = Total \ 10
If (Total = 10 And Data.Substring(6, 1) = "X") Then
Result = Enqueue(Data.Substring(0, 6))
If Result = True Then
Console.WriteLine("Inserted item")
Else
Console.WriteLine("Queue full")
End If
ElseIf Total = Integer.Parse(Data.Substring(6, 1)) Then
Result = Enqueue(Data)
If Result = True Then
Console.WriteLine("Inserted item")
Else
Console.WriteLine("Queue full")
End If
Else
Count = Count + 1
End If
Next
Console.WriteLine("There were " & Count & " invalid items")

End Sub

© Cambridge University Press & Assessment 2024 Page 35 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(d)(i) Python
def StoreItems():
global QueueData
global QueueHead
global QueueTail
Count = 0
for X in range(0, 10):
Data = input("Enter data")
Total= int(Data[0]) + int(Data[1]) * 3 + int(Data[2]) + int(Data[3]) * 3 +
int(Data[4]) + int(Data[5]) * 3
Total = int(Total / 10)
if((Total == 10 and Data[6] == "X") or (Total == int(Data[6]))):
Result = Enqueue(Data[0:6])

if(Result == True):
print("Inserted item")
else:
print("Queue full")
else:
Count = Count + 1

print("There were", Count,"Invalid items")

© Cambridge University Press & Assessment 2024 Page 36 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(d)(ii)  Calling StoreItems() 1


and Dequeue() once
and outputting a suitable message if the queue was empty
and outputting the returned value if the queue was not empty
e.g.
Java
public static void main(String args[]){
for(Integer x = 0; x < 20; x++){
QueueData[x] = "";
}
QueueHead = -1;
QueueTail = -1;
StoreItems();
String Value = Dequeue();
if(Value.compareTo("false") == 0){
System.out.println("No data items");
}else{
System.out.println("Item code " + Value);
}
}
VB.NET
Sub Main(args As String())
For x = 0 To 19
QueueData(x) = ""
Next
StoreItems()
Dim ReturnValue As String = Dequeue()
If (ReturnValue = "false") Then
Console.WriteLine("No data items")
Else
Console.WriteLine("Item code " & ReturnValue)
End If

End Sub

© Cambridge University Press & Assessment 2024 Page 37 of 38


9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2024
PUBLISHED
Question Answer Marks

3(d)(ii) Python
QueueData = []
for x in range(0, 20):
QueueData.append("")
QueueHead = -1
QueueTail = -1
StoreItems()

Value = Dequeue()
if Value == False:
print("No data items")
else:
print("Item code", Value)

3(d)(iii) 1 mark each 2


 Data input of 10 values and output a message saying there are 4 invalid items
 999999 output
e.g.

© Cambridge University Press & Assessment 2024 Page 38 of 38


Cambridge International AS & A Level
* 1 2 6 0 4 7 3 9 2 9 *

COMPUTER SCIENCE 9618/11


Paper 1 Theory Fundamentals May/June 2024

1 hour 30 minutes

You must answer on the question paper.

No additional materials are needed.

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.

This document has 16 pages. Any blank pages are indicated.

DC (DE/SG) 329372/2
© UCLES 2024 [Turn over
2

1 (a) Tick (✓) one box to identify the correct logic statement for this truth table.

A B C X
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 0

NOT (A AND B AND C)

(A XOR B) NOR C

(A OR B OR C) NOR C

NOT A AND NOT B AND NOT C


[1]

(b) Draw a logic circuit for the logic expression:

X = NOT (NOT A AND (NOT B XOR C))

B X

[2]

© UCLES 2024 9618/11/M/J/24


3

2 A video doorbell is attached to the front door of a house. The doorbell uses a motion sensor to
detect when a visitor walks in front of the door. When the motion sensor is activated:

• The digital camera in the doorbell starts recording a video.


• A message is transmitted to a smartphone so that the person who lives in the house can
watch the video.

The doorbell also has a button that can be pressed. When the button is pressed, a message is
transmitted to a smartphone to play the doorbell sound.

The videos are stored on the doorbell’s internal secondary storage device and overwritten when
the secondary storage device is full.

(a) The video doorbell can be considered an example of an embedded system.

Identify two characteristics of the doorbell that suggest it is an embedded system.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................
[2]

(b) State whether the video doorbell is a monitoring system or a control system.
Justify your choice.

Monitoring or control system ....................................................................................................

Justification ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2024 9618/11/M/J/24 [Turn over


4

(c) The video doorbell has both primary memory and secondary storage.

(i) Identify two items of data that the video doorbell will store in primary memory.

1 ........................................................................................................................................

...........................................................................................................................................

2 ........................................................................................................................................

...........................................................................................................................................
[2]

(ii) The video doorbell has a solid state (flash) secondary storage device.

Complete the table by writing the answer or answers to each statement about the
principal operation of solid state (flash) memory.

Statement Answer

the two types of logic gate that 1 .................................................................................


can be used to create solid state
devices 2 .................................................................................

the number of transistors contained


....................................................................................
in each cell

the type of gate that can retain


....................................................................................
electrons without power

the type of gate that allows or stops


....................................................................................
current from passing through

[4]

(iii) The video doorbell uses a buffer.

Describe how the video doorbell will use the buffer.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

© UCLES 2024 9618/11/M/J/24


5

(d) The digital camera has a microphone which is used to record the sound for the video.

The user changes the sampling rate that the microphone uses from 44.1 kHz to 88.2 kHz.

Describe how this change in sampling rate will affect the performance of the video doorbell.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(e) The video doorbell allows both real-time and on-demand bit streaming.

(i) State what is meant by bit streaming.

...........................................................................................................................................

..................................................................................................................................... [1]

(ii) Give two differences between real-time and on-demand bit streaming.

1 ........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

2 ........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[2]

© UCLES 2024 9618/11/M/J/24 [Turn over


6

3 A software developer is writing a computer program.

(a) The developer uses an interpreter while writing the program code because it is easier for
debugging.

Explain one reason why it is easier to debug the program code using an interpreter instead of
a compiler.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) The program is ready to be sold to customers.

The developer uses a compiler because it creates an executable file.

Explain the reasons why the need to create an executable file makes the complier the
appropriate choice when the program is complete.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2024 9618/11/M/J/24


7

BLANK PAGE

© UCLES 2024 9618/11/M/J/24 [Turn over


8

4 The following table shows part of the instruction set for a processor. The processor has two
registers: the Accumulator (ACC) and an Index Register (IX).

Instruction
Explanation
Opcode Operand
LDM #n Immediate addressing. Load the number n to ACC
Direct addressing. Load the contents of the location at the given
LDD <address>
address to ACC
Indirect addressing. The address to be used is at the given address.
LDI <address>
Load the contents of this second address to ACC
Indexed addressing. Form the address from <address> + the contents
LDX <address> of the Index Register. Copy the contents of this calculated address to
ACC
LDR #n Immediate addressing. Load the number n to IX
ADD #n/Bn/&n Add the number n to the ACC
ADD <address> Add the contents of the given address to the ACC
SUB #n/Bn/&n Subtract the number n from the ACC
SUB <address> Subtract the contents of the given address from the ACC
INC <register> Add 1 to the contents of the register (ACC or IX)
<address> can be an absolute or a symbolic address
# denotes a denary number, e.g. #123
B denotes a binary number, e.g. B01001010
& denotes a hexadecimal number, e.g. &4A

© UCLES 2024 9618/11/M/J/24


9

(a) The current contents of memory are shown:

Address Data
19 24
20 2
21 1
22 3
23 5
24 4
25 22

The current contents of the ACC and IX are shown:

ACC 12
IX 1

Complete the table by writing the content of the ACC after each program has run.

Program number Code ACC content

LDD 20
1
ADD #2

2 LDX 22

LDI 25
3 INC ACC
SUB 22
LDD 19
4 LDM #5
LDM #25
[4]

© UCLES 2024 9618/11/M/J/24 [Turn over


10

(b) The processor includes these bit manipulation instructions:

Instruction
Explanation
Opcode Operand
AND #n/Bn/&n Bitwise AND operation of the contents of ACC with the operand
Bitwise AND operation of the contents of ACC with the contents of
AND <address>
<address>
XOR #n/Bn/&n Bitwise XOR operation of the contents of ACC with the operand
Bitwise XOR operation of the contents of ACC with the contents of
XOR <address>
<address>
OR #n/Bn/&n Bitwise OR operation of the contents of ACC with the operand
Bitwise OR operation of the contents of ACC with the contents of
OR <address>
<address>
<address> can be an absolute or a symbolic address
# denotes a denary number, e.g. #123
B denotes a binary number, e.g. B01001010
& denotes a hexadecimal number, e.g. &4A

The current contents of memory are shown:

Address Data
30 01110101
31 11111111
32 00000000
33 11001100
34 10101010

The current content of the ACC is shown:

1 0 0 1 1 0 1 0

Complete the table by writing the content of the ACC after each program has run.

The binary number 10011010 is reloaded into the ACC before each program is run.

Program number Code ACC content

1 AND 31

2 XOR B01001111

3 OR #30

[3]
© UCLES 2024 9618/11/M/J/24
11

5 A bank allows customers to access their accounts using an application that they can download
onto a device such as a smartphone.

(a) The system that allows customers to access their accounts using the application is a
client-server model.

Describe the roles of the different devices in this model.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

(b) The bank wants to protect the integrity of its data while transferring the data to other banks.
Parity check is one example of data verification.

Complete the description of parity check when Computer A is transmitting data to Computer B.

Computer A and Computer B agree on whether to use ......................................................

parity. Computer A divides the data into groups of ...................................................... . The

number of 1s in each group is counted. If the agreed parity is ................................................

and the group has an even number of 1s, a parity bit of 1 is appended, otherwise a parity bit

of 0 is appended.

In a parity ...................................................... check the bytes are grouped together, for

example in a grid. The number of 1s in each column (bit position) is counted. A bit is assigned

to each column to make the column match the parity. These parity bits are transmitted with

the data as a parity ...................................................... .


[5]

© UCLES 2024 9618/11/M/J/24 [Turn over


12

(c) The bank also needs to keep its customers’ data private and secure.

(i) The bank’s network has a firewall.

Explain how a firewall can help protect the customers’ data.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

(ii) Customers need to use biometric authentication to access their accounts.


One biometric authentication method is facial recognition.

Facial recognition uses Artificial Intelligence (AI).

Describe how AI is used in facial recognition.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [4]

© UCLES 2024 9618/11/M/J/24


13

6 A company is developing a website that will allow users to create an account and then play a quiz
every day. The data about the users and the quizzes are stored in a database.

A user must select a unique username and enter a valid email address to create an account. All
users must be over the age of 16. A new quiz is given to the users every day. Each quiz is stored
in its own text file.

The database stores the filename of each quiz and the date it can be played. The user gets a
score for each quiz they complete, which is stored in the database. The scores are used to give
each user a rating, for example Gold.

(a) Create a 3-table design for this database normalised to Third Normal Form (3NF).

Give your table design in the format:

TableName(PrimaryKey, Field1, Field2, …)

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

(b) The company is using a Database Management System (DBMS) to set up the database.

Describe what is meant by the following DBMS features:

Data dictionary ..........................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Logical schema .........................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]
© UCLES 2024 9618/11/M/J/24 [Turn over
14

(c) The company has another database, FARMING, for a different game.

The database FARMING has a table named EVENT which is shown with some sample data.

PlayerID EventID Category Points


000123 3 Build 100
000124 1 Grow 36
000123 4 Grow 22
000123 7 Create 158
000125 3 Grow 85
000125 4 Build 69

(i) The database FARMING has a second table created named PLAYER that has the primary
key PlayerID.

The field PlayerID in EVENT needs to be set up as a foreign key to link to PlayerID in
PLAYER.

Write a Structured Query Language (SQL) script to change the table definition for EVENT
to link the foreign key to PLAYER.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) Write an SQL script to return the number of events that each player has completed.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

© UCLES 2024 9618/11/M/J/24


15

7 Complete the binary addition. Show your working.

10011110
01100001
+00011001

[3]

© UCLES 2024 9618/11/M/J/24 [Turn over


16

8 A business is creating a local area network (LAN) in its office.

(a) The business is deciding which topology to use.

Tick (✓) one or more boxes in each row to identify the topology, or topologies, each statement
describes.

Statement Bus Star Mesh

all devices connect to one central device

all devices connect to a central cable

multiple paths for the packets to travel along

robust against damage because if any line fails,


the rest of the network retains full functionality

most likely to lose data through collisions

[5]

(b) The LAN will connect to the internet through a router. The router has a public IPv6 address.

(i) State why the router has a public IP address.

...........................................................................................................................................

..................................................................................................................................... [1]

(ii) One difference between an IPv4 and IPv6 address is that the numbers in an IPv4 address
are separated by full stops and in an IPv6 address they are separated by colons.

Identify two other differences between an IPv4 and IPv6 address.

1 ........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

2 ........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[2]
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 2024 9618/11/M/J/24


Cambridge International AS & A Level
* 9 0 9 1 5 1 7 7 3 8 *

COMPUTER SCIENCE 9618/12


Paper 1 Theory Fundamentals May/June 2024

1 hour 30 minutes

You must answer on the question paper.

No additional materials are needed.

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.

This document has 16 pages. Any blank pages are indicated.

DC (CE/SG) 329373/3
© UCLES 2024 [Turn over
2

1 (a) Describe the operation of each of the following logic gates:

NAND .......................................................................................................................................

...................................................................................................................................................

NOR ..........................................................................................................................................

...................................................................................................................................................

XOR ..........................................................................................................................................

...................................................................................................................................................

OR ............................................................................................................................................

...................................................................................................................................................
[4]

(b) Draw a logic circuit for this logic expression:

X = NOT ((A AND B) OR (C AND D))

[2]

© UCLES 2024 9618/12/M/J/24


3

2 A computer game is being designed that users will be able to play using a virtual reality (VR)
headset.

(a) Complete the description of the principal operation of a VR headset.

A headset can have one or two .......................................................... that output the image to

the user. The headset has speakers that output surround sound to give a realistic experience.

The user’s head movements are detected using a sensor.

This sensor is a .......................................................... . The data is transmitted to a

microprocessor that analyses the data to identify the .......................................................... of

movement. Some headsets use .......................................................... that record the user’s

eye movements for analysis.


[4]

(b) The computer uses a buffer when transmitting data to the VR headset.

Explain how a buffer is used when data is transmitted between the computer and the VR
headset.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) The VR headset has Electrically Erasable Programmable Read Only Memory (EEPROM).

Explain the benefits of using EEPROM instead of other types of Read Only Memory (ROM) in
the VR headset.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2024 9618/12/M/J/24 [Turn over


4

(d) The computer can transmit a video made from bitmap images and vector graphic animations
to the VR headset.

(i) Describe how the data for a bitmapped image is encoded.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

(ii) Describe the contents of a vector graphic drawing list.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(iii) The bitmap video is not compressed before transmission to the VR headset.

Give two reasons why the video does not need to be compressed.

1 ........................................................................................................................................

...........................................................................................................................................

2 ........................................................................................................................................

...........................................................................................................................................
[2]

© UCLES 2024 9618/12/M/J/24


5

3 An assessment board scans exam papers and stores the digitised papers on a server. Exam
markers download the digitised papers to mark. The exam markers then upload the mark for each
paper.

(a) The assessment board needs to make sure the data stored on the server is secure.

(i) Authentication methods can help to protect the server against hackers.

Identify one other security measure that helps to protect the server from hackers.

Describe how the security measure works.

Security measure ..............................................................................................................

Description ........................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[3]

(ii) Identify one security measure that helps to protect the data when it is being transmitted
to its destination. Describe how the security measure works.

Security measure ..............................................................................................................

Description ........................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[3]

© UCLES 2024 9618/12/M/J/24 [Turn over


6

(b) The exam markers use software that operates as a thin-client to mark the exam papers.

Complete the table by identifying two characteristics of a thin-client.

Describe how each characteristic will be used in this software.

Thin-client characteristic Description of use in this software

1
............................................................. ........................................................................

............................................................. ........................................................................

............................................................. ........................................................................

............................................................. ........................................................................

2
............................................................. ........................................................................

............................................................. ........................................................................

............................................................. ........................................................................

............................................................. ........................................................................

[4]

(c) Data transmitted on the internet passes through multiple different systems.

(i) Describe the role of routers in the transmission of data through the internet.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) Describe the role of the PSTN (Public Switched Telephone Network) in the transmission
of data through the internet.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

© UCLES 2024 9618/12/M/J/24


7

4 An assessment board wants to store the marks students achieved in exams in a database named
RECORDS.

Part of the database design includes these two tables:

EXAM(ExamID, Subject, Level, TotalMarks)

EXAM_QUESTION(ExamQuestionID, ExamID, QuestionNumber, Question, MaxMark)

(a) Identify the relationship between EXAM and EXAM_QUESTION.

...................................................................................................................................................

............................................................................................................................................. [1]

(b) Sample data for the table EXAM is shown:

ExamID Subject Level TotalMarks


00956124 Computer Science 2 75
00956125 Computer Science 3 120
00956126 Mathematics 2 100
00956127 Mathematics 3 150
00956128 Physics 2 70
00956129 Physics 3 80

Write a Structured Query Language (SQL) script to define the table EXAM.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2024 9618/12/M/J/24 [Turn over


8

(c) The table EXAM_QUESTION has been created but the foreign key has not been linked.

Write an SQL script to update EXAM_QUESTION and link the foreign key to EXAM.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(d) The database also needs to store data about the students, the exams the students have
taken and the marks the students achieved in each question of each exam.

Describe the additional tables that will need to be included in the database and explain how
all the tables in the database will be linked.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

© UCLES 2024 9618/12/M/J/24


9

BLANK PAGE

© UCLES 2024 9618/12/M/J/24 [Turn over


10

5 The following table shows part of the instruction set for a processor. The processor has two
registers: the Accumulator (ACC) and an Index Register (IX).

Instruction
Explanation
Opcode Operand
LDM #n Immediate addressing. Load the number n to ACC
Direct addressing. Load the contents of the location at the given
LDD <address>
address to ACC
Indirect addressing. The address to be used is at the given address.
LDI <address>
Load the contents of this second address to ACC
Indexed addressing. Form the address from <address> + the contents
LDX <address> of the index register. Copy the contents of this calculated address to
ACC
LDR #n Immediate addressing. Load the number n to IX
ADD #n/Bn/&n Add the number n to the ACC
ADD <address> Add the contents of the given address to the ACC
SUB #n/Bn/&n Subtract the number n from the ACC
SUB <address> Subtract the contents of the given address from the ACC
INC <register> Add 1 to the contents of the register (ACC or IX)
<address> can be an absolute or a symbolic address
# denotes a denary number, e.g. #123
B denotes a binary number, e.g. B01001010
& denotes a hexadecimal number, e.g. &4A

© UCLES 2024 9618/12/M/J/24


11

(a) The current contents of memory are shown:

Address Data
10 1
11 3
12 5
13 11
14 10
15 16
16 12

The current contents of the ACC and IX are shown:

ACC 10
IX 0

Complete the table by writing the content of the ACC after each program has run.

Program number Code ACC content

LDI 15
1
SUB #1

LDD 14
2
ADD 11

LDM #11
3 ADD #3
SUB 16
LDR #2
4 LDX 14
ADD #2
[4]

© UCLES 2024 9618/12/M/J/24 [Turn over


12

(b) The processor includes these bit manipulation instructions:

Instruction
Explanation
Opcode Operand
AND #n/Bn/&n Bitwise AND operation of the contents of ACC with the operand
Bitwise AND operation of the contents of ACC with the contents of
AND <address>
<address>
XOR #n/Bn/&n Bitwise XOR operation of the contents of ACC with the operand
Bitwise XOR operation of the contents of ACC with the contents of
XOR <address>
<address>
OR #n/Bn/&n Bitwise OR operation of the contents of ACC with the operand
Bitwise OR operation of the contents of ACC with the contents of
OR <address>
<address>
<address> can be an absolute or a symbolic address
# denotes a denary number, e.g. #123
B denotes a binary number, e.g. B01001010
& denotes a hexadecimal number, e.g. &4A

The current contents of memory are shown:

Address Data
25 11000110
26 11100001
27 10000001
28 11001101
29 00001111

The current content of the ACC is shown:

0 1 0 0 0 1 1 0

Complete the table by writing the content of the ACC after each program has run.

The binary number 01000110 is reloaded into the ACC before each program is run.

Program number Code ACC content

1 XOR 29

2 AND #29

3 OR B11111111

[3]

© UCLES 2024 9618/12/M/J/24


13

6 A computer has an Operating System (OS).

Memory management and process management are two OS tasks.

Explain how memory management and process management support multi-tasking.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [4]

© UCLES 2024 9618/12/M/J/24 [Turn over


14

7 A computer stores binary data.

(a) Tick (3) one box only to identify the largest file size.

3300 kibibytes

0.3 megabytes

3 mebibytes

3300 kilobytes
[1]

(b) Subtract the denary number 10 from the denary number 100 using binary subtraction.

Show your working.

Working .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Answer ....................................
[3]

(c) Convert the hexadecimal number C0F into denary.

Show your working.

Working .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Answer ....................................
[2]

© UCLES 2024 9618/12/M/J/24


15

8 A programmer uses an Integrated Development Environment (IDE) to write a computer program.


The IDE has both a compiler and an interpreter as built-in translators.

(a) The programmer decides to use the compiler when testing the final program.

Describe the benefits of using the compiler during testing.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) IDEs have many features other than built-in translators.

Complete the table by identifying one other common IDE feature that can be used for each
purpose. Describe how each feature helps the user during program development.

Each feature must be different. Do not give translator as one of your features.

Purpose IDE feature Description

..................................................................................

..................................................................................
..................................
for
coding ..................................................................................
..................................
..................................................................................

..................................................................................

..................................................................................
..................................
for
presentation ..................................................................................
..................................
..................................................................................

..................................................................................

..................................................................................
..................................
for
debugging ..................................................................................
..................................
..................................................................................

[6]

© UCLES 2024 9618/12/M/J/24 [Turn over


16

(c) The programmer uses program libraries when developing the program.

Describe two benefits to the programmer of using program libraries.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................
[2]

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 2024 9618/12/M/J/24


* 0019655335901 *

,  ,

Cambridge International AS & A Level

¬OŠ. 3mIsW™EªQ‰f W
¬š–a=§h8Y‚~9]›ndf‚
¥UUU5•¥u• 5• EE uU
* 4 9 7 7 2 5 9 3 4 5 *

COMPUTER SCIENCE 9618/13


Paper 1 Theory Fundamentals May/June 2024

1 hour 30 minutes

You must answer on the question paper.

No additional materials are needed.

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.

This document has 16 pages.

DC (KS/SG) 329374/2
© UCLES 2024 [Turn over
* 0019655335902 *

DO NOT WRITE IN THIS MARGIN


2
,  ,

1 (a) Complete the following description.

A kibibyte has a ................................................ prefix. Three kibibytes is the same

as ................................................ bytes.

A megabyte has a ................................................ prefix. Two terabytes is the same

as ................................................ gigabytes.
[4]

DO NOT WRITE IN THIS MARGIN


(b) Convert the denary number 241 to hexadecimal.

...................................................................................................................................................

............................................................................................................................................. [1]

(c) State what is meant by an overflow in binary addition.

...................................................................................................................................................

............................................................................................................................................. [1]

DO NOT WRITE IN THIS MARGIN


(d) Computers use character sets when representing characters in binary.

(i) Complete the table by identifying the number of bits each of the character sets allocates
to each character.

Character set Number of bits

ASCII

extended ASCII

Unicode

DO NOT WRITE IN THIS MARGIN


[1]

(ii) Explain how the word ‘Clock’ is represented by a character set.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]
DO NOT WRITE IN THIS MARGIN

ĬÍĊ®Ġ³íÉó×ęÅĪÔċèĞ×
© UCLES 2024 ĬĚĘâÀģäÒâïüÖĕġ¾ĜÞĂ
ĥąÅÕõõåĕåÅĥÕąąåÅÕÕ
9618/13/M/J/24
* 0019655335903 *
DO NOT WRITE IN THIS MARGIN

3
,  ,

2 A photograph is stored as a bitmap image.

(a) The photograph has a resolution of 4000 pixels wide by 3000 pixels high. The bit depth is
4 bytes.

Calculate an estimate for the file size of the photograph in megabytes.

Show your working.

Working .....................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

Answer ...................................... megabytes


[2]

(b) The photograph is compressed before being uploaded to a web server.

(i) Give three benefits of this photograph being compressed using lossy compression
instead of lossless compression.
DO NOT WRITE IN THIS MARGIN

1 ........................................................................................................................................

...........................................................................................................................................

2 ........................................................................................................................................

...........................................................................................................................................

3 ........................................................................................................................................

...........................................................................................................................................
[3]
DO NOT WRITE IN THIS MARGIN

(ii) Explain how run-length encoding (RLE) will compress the photograph.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(c) Identify two elements of a bitmap image that can be changed to reduce its file size.

1 ................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................
[2]
ĬÏĊ®Ġ³íÉó×ęÅĪÔĉèĞ×
© UCLES 2024 ĬĚėáÈĥàâ×ĉąēÁęĚĜÎĂ
ĥąµĕµĕÅõµµµÕąĥÅąÅÕ
9618/13/M/J/24 [Turn over
* 0019655335904 *

DO NOT WRITE IN THIS MARGIN


4
,  ,

3 The following table shows part of the instruction set for a processor. The processor has two
registers: the Accumulator (ACC) and an Index Register (IX).

Instruction
Explanation
Opcode Operand
LDM #n Immediate addressing. Load the number n to ACC

Direct addressing. Load the contents of the location at the given


LDD <address>
address to ACC

DO NOT WRITE IN THIS MARGIN


Indirect addressing. The address to be used is at the given address.
LDI <address>
Load the contents of this second address to ACC
Indexed addressing. Form the address from <address> + the contents
LDX <address> of the index register. Copy the contents of this calculated address to
ACC
LDR #n Immediate addressing. Load the number n to IX

ADD #n/Bn/&n Add the number n to the ACC

ADD <address> Add the contents of the given address to the ACC

DEC <register> Subtract 1 from the contents of the register (ACC or IX)

DO NOT WRITE IN THIS MARGIN


SUB #n/Bn/&n Subtract the number n from the ACC

SUB <address> Subtract the contents of the given address from the ACC

INC <register> Add 1 to the contents of the register (ACC or IX)

<address> can be an absolute or a symbolic address


# denotes a denary number, e.g. #123
B denotes a binary number, e.g. B01001010
& denotes a hexadecimal number, e.g. &4A

DO NOT WRITE IN THIS MARGIN


DO NOT WRITE IN THIS MARGIN

ĬÍĊ®Ġ³íÉó×ęÅĪÒċèĠ×
© UCLES 2024 ĬĚėäÈğÎçäćþĜ쵼ȿĂ
ĥµĥĕõĕÅÕÕĕÅÕÅĥĥąÕÕ
9618/13/M/J/24
* 0019655335905 *
DO NOT WRITE IN THIS MARGIN

5
,  ,

(a) The current contents of memory are shown:

Address Data

48 51
49 6
50 48
51 50
DO NOT WRITE IN THIS MARGIN

52 49
53 50
54 6

The current contents of the ACC and IX are shown:

ACC 2
IX 50

Complete the table by writing the content of the ACC after each program has run.
DO NOT WRITE IN THIS MARGIN

Program number Code ACC content

LDM #50
1 INC ACC
SUB #1

LDI 51
2
ADD 52

LDR #2
DO NOT WRITE IN THIS MARGIN

LDX 50
3
DEC ACC

LDD 52
4 SUB 54
INC ACC

[4]
DO NOT WRITE IN THIS MARGIN

ĬÏĊ®Ġ³íÉó×ęÅĪÒĉèĠ×
© UCLES 2024 ĬĚĘãÀĩÒ×ÕñóÍ·½ĠČÖĂ
ĥµĕÕµõåµÅĥĕÕÅąąÅÅÕ
9618/13/M/J/24 [Turn over
* 0019655335906 *

DO NOT WRITE IN THIS MARGIN


6
,  ,

(b) The processor includes these bit manipulation instructions:

Instruction
Explanation
Opcode Operand
AND #n/Bn/&n Bitwise AND operation of the contents of ACC with the operand
Bitwise AND operation of the contents of ACC with the contents of
AND <address>
<address>
XOR #n/Bn/&n Bitwise XOR operation of the contents of ACC with the operand

DO NOT WRITE IN THIS MARGIN


Bitwise XOR operation of the contents of ACC with the contents of
XOR <address>
<address>
OR #n/Bn/&n Bitwise OR operation of the contents of ACC with the operand
Bitwise OR operation of the contents of ACC with the contents of
OR <address>
<address>
Bits in ACC are shifted logically n places to the left. Zeros are
LSL #n
introduced on the right-hand end
Bits in ACC are shifted logically n places to the right. Zeros are
LSR #n
introduced on the left-hand end

DO NOT WRITE IN THIS MARGIN


<address> can be an absolute or a symbolic address
# denotes a denary number, e.g. #123
B denotes a binary number, e.g. B01001010
& denotes a hexadecimal number, e.g. &4A

The current contents of memory are shown:

Address Data
100 00001101
101 10111110

DO NOT WRITE IN THIS MARGIN


102 11110011
103 00110111
104 00000000

The current content of the ACC is shown:

1 1 1 1 1 1 1 1
DO NOT WRITE IN THIS MARGIN

ĬÑĊ®Ġ³íÉó×ęÅĪÓĉåĞ×
© UCLES 2024 ĬĚėãÃģºÍÍöĂè×µýäæĂ
ĥĥµÕµÕåĕąąµÕąąåąĕÕ
9618/13/M/J/24
* 0019655335907 *
DO NOT WRITE IN THIS MARGIN

7
,  ,

Complete the table by writing the content of the ACC after each instruction has run.

The binary number 11111111 is reloaded into the ACC before each instruction is run.

Instruction number Instruction ACC content

1 LSL #2

2 XOR 100
DO NOT WRITE IN THIS MARGIN

3 AND 103

[3]
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN

ĬÓĊ®Ġ³íÉó×ęÅĪÓċåĞ×
© UCLES 2024 ĬĚĘäËĥ¶ÝìĄïġă½ÙäÖĂ
ĥĥÅĕõµÅõĕõĥÕąĥÅÅąÕ
9618/13/M/J/24 [Turn over
* 0019655335908 *

DO NOT WRITE IN THIS MARGIN


8
,   ,

4 A theatre wants to use a database to store data about the shows that are scheduled, their
customers and the seats that the customers have booked.

In the theatre:

• Each show can take place on multiple dates.


• Some dates can have more than one performance.
• There are multiple rows of seats.
• Each seat can be individually booked by its row letter and seat number, for example row E
seat 2.

DO NOT WRITE IN THIS MARGIN


Part of the database design includes these tables:
SHOW(ShowID, Title, Duration)
SEAT(SeatID, RowLetter, SeatNumber)
PERFORMANCE(PerformanceID, ShowID, ShowDate, StartTime)

(a) Identify the relationship between the tables PERFORMANCE and SHOW.

...................................................................................................................................................

............................................................................................................................................. [1]

DO NOT WRITE IN THIS MARGIN


(b) Sample data for the table PERFORMANCE is shown:

PerformanceID ShowID ShowDate StartTime

0001 MK12 5/5/2025 13:00


0002 MK12 5/5/2025 19:30
0003 MK12 6/5/2025 19:00
0004 OP3 7/5/2025 18:30
0005 OP3 8/5/2025 18:30
0006 OP3 9/5/2025 13:00

DO NOT WRITE IN THIS MARGIN


Write a Structured Query Language (SQL) script to define the table PERFORMANCE.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]
ĬÑĊ®Ġ³íÉó×ęÅĪÑĉåĠ×
© UCLES 2024 ĬĚĘáËğÈìÏþøĪáġû´ÞĂ
ĥÕĕĕµµÅÕõÕĕÕÅĥĥÅĕÕ
9618/13/M/J/24
* 0019655336009 *
DO NOT WRITE IN THIS MARGIN

9
,  ,

(c) Write an SQL script to return the number of times each show is scheduled. For example, in
the sample data in part (b), the show MK12 is scheduled three times.

The result needs to include the show name and a suitable field name for the number of times
it is scheduled.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

(d) Customers give their first name, last name and email address when they are making a
DO NOT WRITE IN THIS MARGIN

booking. One booking can include multiple seats.

Describe the additional tables that will need to be included in the database and explain how
these tables will be linked within the database.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]
DO NOT WRITE IN THIS MARGIN

ĬÓĉ¯Ġ³íÉó×ęÅĪÒĉåĠ×
© UCLES 2024 ĬĚĘãÈĤ·¾àÿČÍĚáûĄÖĂ
ĥĥµÕµĕĥµĕÕµÕąåĥąåÕ
9618/13/M/J/24 [Turn over
* 0019655336010 *

DO NOT WRITE IN THIS MARGIN


10
, ,

5 A multimedia design company has an office with a LAN (local area network). The LAN can have
up to 20 devices connected with cables and other devices connected using wireless access.

(a) The company has private cloud storage for its employees to store their work.

(i) Define the term private cloud.

...........................................................................................................................................

..................................................................................................................................... [1]

DO NOT WRITE IN THIS MARGIN


(ii) Describe the benefits to the company of using private cloud storage instead of public
cloud storage.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

DO NOT WRITE IN THIS MARGIN


..................................................................................................................................... [3]

(b) Part of the internal structure of the wired LAN is a star topology.

Explain how packets are transmitted between two devices in a star topology.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

DO NOT WRITE IN THIS MARGIN


............................................................................................................................................. [2]

DO NOT WRITE IN THIS MARGIN

ĬÑĉ¯Ġ³íÉó×ęÅĪÓċçĞ×
© UCLES 2024 ĬĚĖäÅĨ³ì×òî²âÛ˼ÎĂ
ĥµåÕõõåÕåĕĥĕąĥąÅąÕ
9618/13/M/J/24
* 0019655336011 *
DO NOT WRITE IN THIS MARGIN

11
, ,

(c) A different part of the network uses the Ethernet protocol.

(i) A collision is detected.

Describe how the collision is managed using Carrier Sense Multiple Access/Collision
Detection (CSMA/CD).

...........................................................................................................................................

...........................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) Identify two drawbacks of using CSMA/CD.

1 ........................................................................................................................................

...........................................................................................................................................

2 ........................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...........................................................................................................................................
[2]

(d) The devices in the office have static private IP addresses.

State what is meant by a static private IP address.

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [1]
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN

ĬÓĉ¯Ġ³íÉó×ęÅĪÓĉçĞ×
© UCLES 2024 ĬĚĕã½Ģ¯ÜâĈă÷öãď¼ÞĂ
ĥµÕĕµĕŵµĥµĕąąĥąĕÕ
9618/13/M/J/24 [Turn over
* 0019655336012 *

DO NOT WRITE IN THIS MARGIN


12
, ,

6 Each of the following truth tables has three inputs (A, B and C) and one output (X).

Draw one line to match each truth table with its logic expression.

Truth table Logic expression

A B C X
0 0 0 0 NOT (A XOR B) AND C
0 0 1 1

DO NOT WRITE IN THIS MARGIN


0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 0
(A OR C) AND NOT B
1 1 1 0

A B C X
0 0 0 0

DO NOT WRITE IN THIS MARGIN


0 0 1 1
0 1 0 0
0 1 1 0 A NAND B NAND C
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 1

DO NOT WRITE IN THIS MARGIN


A B C X
(A NAND B) OR C
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 1
NOT (A AND B AND C)
1 1 0 0
DO NOT WRITE IN THIS MARGIN

1 1 1 1
[3]

ĬÑĉ¯Ġ³íÉó×ęÅĪÑċçĠ×
© UCLES 2024 ĬĚĕâ½Ĭ½ÍÕĊČðØÿ­ìÖĂ
ĥąąĕõĕÅĕÕÅÅĕÅąÅąąÕ
9618/13/M/J/24
* 0019655336013 *
DO NOT WRITE IN THIS MARGIN

13
, ,

7 Robots are used to serve food and drink to customers at a restaurant.


DO NOT WRITE IN THIS MARGIN

(a) A robot navigates through the restaurant to the table it is serving.

Complete the table by identifying two sensors that can be included in the robot and the
purpose of each sensor in the navigation system.
DO NOT WRITE IN THIS MARGIN

Sensor Purpose of sensor in navigation system

.............................................. ..........................................................................................

.............................................. ..........................................................................................

.............................................. ..........................................................................................

.............................................. ..........................................................................................
[2]
DO NOT WRITE IN THIS MARGIN

(b) The robot uses Artificial Intelligence (AI) to communicate with the customers. The customers
speak to the robot to order their food and drinks.

Explain how AI will be used in this part of the robot.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]
ĬÓĉ¯Ġ³íÉó×ęÅĪÑĉçĠ×
© UCLES 2024 ĬĚĖáÅĞÁÝäðõ¹Ą÷ĩìæĂ
ĥąõÕµõåõŵĕĕÅĥåÅĕÕ
9618/13/M/J/24 [Turn over
* 0019655336014 *

DO NOT WRITE IN THIS MARGIN


14
, ,

(c) The navigation system can be considered an example of a control system.

Describe how feedback is used in a control system.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

DO NOT WRITE IN THIS MARGIN


(d) The robot includes a touchscreen for the customer to make their payment.

Describe the principal operation of a touchscreen.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

DO NOT WRITE IN THIS MARGIN


...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

DO NOT WRITE IN THIS MARGIN


DO NOT WRITE IN THIS MARGIN

ĬÍĉ¯Ġ³íÉó×ęÅĪÒĊæĢ×
© UCLES 2024 ĬĚĕãÈĤ®ÕÒúòĖàÞĝĜÞĂ
ĥåõĕõĕĥÕååĕÕąåąąÅÕ
9618/13/M/J/24
* 0019655336015 *
DO NOT WRITE IN THIS MARGIN

15
, ,

(e) Program libraries were used when writing the robot’s software.

(i) State what is meant by a program library.

...........................................................................................................................................

..................................................................................................................................... [1]

(ii) Some program libraries include Dynamic Link Library (DLL) files.

Describe the benefits of a programmer using a library with DLL files instead of using a
DO NOT WRITE IN THIS MARGIN

library that does not include DLL files.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [4]
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN

ĬÏĉ¯Ġ³íÉó×ęÅĪÒČæĢ×
© UCLES 2024 ĬĚĖäÀĦ²åçĀÿÓüÖ¹ĜÎĂ
ĥåąÕµõąµµÕÅÕąÅĥÅÕÕ
9618/13/M/J/24 [Turn over
* 0019655336016 *

DO NOT WRITE IN THIS MARGIN


16
, ,

(f) The data from the robots is transmitted to a central computer using a wireless connection.

(i) Complete the table by identifying and describing two methods of data verification that
can be used during data transfer.

Method Description
1
..........................................................................................

......................................... ..........................................................................................

DO NOT WRITE IN THIS MARGIN


......................................... ..........................................................................................

..........................................................................................

..........................................................................................

..........................................................................................

2
..........................................................................................

DO NOT WRITE IN THIS MARGIN


......................................... ..........................................................................................

......................................... ..........................................................................................

..........................................................................................

..........................................................................................

..........................................................................................

[4]

(ii) Explain how encryption can protect the security of data during transmission.

DO NOT WRITE IN THIS MARGIN


...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]
DO NOT WRITE IN THIS MARGIN

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 2024 ĬĚĖáÀĠÄäÔĂĈÜÚúěČæĂ
ĥĕÕÕõõąĕÕõµÕÅÅÅÅÅÕ
9618/13/M/J/24
Cambridge International AS & A Level
* 8 4 1 6 1 0 0 9 4 2 *

COMPUTER SCIENCE 9618/21


Paper 2 Fundamental Problem-solving and Programming Skills May/June 2024

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 24 pages. Any blank pages are indicated.

DC (PQ/CGW) 329348/4
© UCLES 2024 [Turn over
2

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

1 An algorithm is developed in pseudocode before being coded in a programming language.

(a) The following table shows four valid pseudocode assignment statements.

Complete the table by giving an appropriate data type to declare each of the variables A, B, C
and D.

Assignment statement Data type


A LEFT(MyName, 1)
B Total * 2
C INT(ItemCost) / 3
D "Odd OR Even"
[4]

(b) Other variables in the program have example values as shown:

Variable Value

Sorted False

Tries 9

ID "ZGAC001"

Complete the table by evaluating each expression, using the example values.

Expression Evaluates to

Tries < 10 AND NOT Sorted

Tries MOD 4

TO_LOWER(MID(ID, 3, 1))

LENGTH(ID & "xx") >= Tries


[4]

© UCLES 2024 9618/21/M/J/24


3

(c) The variable names A, B, C and D in part (a) are not good programming practice.

(i) State why these variable names are not suitable.

...........................................................................................................................................

..................................................................................................................................... [1]

(ii) Identify one problem that these variable names might cause.

...........................................................................................................................................

..................................................................................................................................... [1]

(iii) The choice of suitable variable names is one example of good programming practice.

Give one other example.

...........................................................................................................................................

..................................................................................................................................... [1]

© UCLES 2024 9618/21/M/J/24 [Turn over


4

2 An algorithm has three steps. It will:


1. repeatedly input a pair of numeric values A and B
2. count the number of pairs that are input until A has been greater than B 10 times
3. output the number of pairs that were input.

(a) Complete the program flowchart.

START

INPUT A, B

Yes

No

END

[5]
© UCLES 2024 9618/21/M/J/24
5

(b) Step 1 of the algorithm is changed.

A variable ThisSequence is used to enter a sequence of 10 pairs of numeric values, using


a single input statement.

Following the input of ThisSequence the revised algorithm will extract the pairs of numbers.

Describe the variable ThisSequence and how the numbers are extracted.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2024 9618/21/M/J/24 [Turn over


6

3 The diagram shows an Abstract Data Type (ADT) representation of a linked list after data items
have been added.

• PS is the start pointer.


• PF is the free list pointer.
• Labels Df, Dc, Db and Dy represent the data items of nodes in the list.
• Labels Fg, Fh, Fm and Fw represent the data items of nodes in the free list.
• The symbol Ø represents a null pointer.

PS
Df Dc Db Dy Ø

PF
Fg Fh Fm Fw Ø

(a) Describe the linked list immediately after initialisation, before any data items are added.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2024 9618/21/M/J/24


7

(b) A program will be written to include a linked list to store alphanumeric user IDs.

The design uses two variables and two 1D arrays to implement the linked list.
Each array element contains data of a single data type and not a record.

The statements below describe the design.

Complete the statements.

The two variables will be of type ............................................................................................. .

The two variables will be used as ....................................................................... to the arrays.

The values stored in the two variables will indicate ..................................................................

................................................................................................................................................. .

The first 1D array will be of type ............................................................................................. .

The first 1D array will be used to ............................................................................................ .

The second 1D array will be of type ....................................................................................... .

The second 1D array will be used to ...................................................................................... .


[5]

© UCLES 2024 9618/21/M/J/24 [Turn over


8

4 A global 1D array Data contains 100 elements of type integer.

A function Check() will:

• total the element values in odd index locations (1, 3, 5 ... 97, 99)
• total the element values in even index locations (2, 4, 6 ... 98, 100)
• return one of three strings ‘Odd’, ‘Even’ or ‘Same’ to indicate which total is the greater, or
whether the totals are the same.

Write pseudocode for the function Check().

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [6]

© UCLES 2024 9618/21/M/J/24


9

BLANK PAGE

© UCLES 2024 9618/21/M/J/24 [Turn over


10

5 A global 1D array of strings contains three elements which are assigned values as shown:

Data[1] "aaaaaa"
Data[2] "bbbbbb"
Data[3] "cccccc"

Procedure Process() manipulates the values in the array.

The procedure is written in pseudocode as follows:

PROCEDURE Process(Format : STRING)


DECLARE Count, Index, L : INTEGER
DECLARE Result : STRING
DECLARE C : CHAR

Result "****"

FOR Count 1 TO LENGTH(Format) STEP 2


C MID(Format, Count, 1)
L STR_TO_NUM(MID(Format, Count + 1, 1))

Index (Count + 1) DIV 2

CASE OF C
'X' : Result TO_UPPER(Data[Index])
'Y' : Result TO_LOWER(Data[Index])
'Z' : Result "**" & Data[Index]
ENDCASE

Data[Index] LEFT(Result, L)
NEXT Count

ENDPROCEDURE

© UCLES 2024 9618/21/M/J/24


11

(a) Complete the trace table by dry running the procedure when it is called as follows:

CALL Process("X3Y2W4")

Count C L Index Result Data[1] Data[2] Data[3]

[6]

(b) The procedure is to be modified. If variable C is assigned a value other than 'X', 'Y' or 'Z',
then procedure Error() is called and passed the value of variable C as a parameter.

This modification can be implemented by adding a single line of pseudocode.

(i) Write the single line of pseudocode.

..................................................................................................................................... [1]

(ii) State where this new line should be placed.

..................................................................................................................................... [1]

© UCLES 2024 9618/21/M/J/24 [Turn over


12

6 Three points on a grid form a triangle with sides of length A, B and C as shown in the example:

10
9
8
7
6
5 B C
4
3
2 A
1
x
0 1 2 3 4 5 6 7 8 9 10

A triangle is said to be right-angled if the following test is true (where A is the length of the longest
side):

A2 = B2 + C2

A2 means A multiplied by A, for example 32 means 3 × 3 which evaluates to 9

You can calculate A2, B2 and C2 by using the coordinates of the endpoints of each line.

For example, B2 is calculated as follows:

10
9
8
7
P2
6 (x2, y2)
5 B
4
3
P1
2 (x1, y1)
1
x
0 1 2 3 4 5 6 7 8 9 10

The endpoints, P1 and P2, have the coordinates (3, 2) and (6, 6).

The value B2 is given by the formula:

B2 = (x1 − x2)2 + (y1 − y2)2

In this example:

B2 = (3 − 6)2 + (2 − 6)2
B2 = (–3)2 + (–4)2
B2 = 9 + 16
B2 = 25

© UCLES 2024 9618/21/M/J/24


13

(a) A function IsRA() will:

• take three sets of integers as parameters representing the coordinates of the three
endpoints that form a triangle
• return TRUE if the endpoints form a right-angled triangle, otherwise return FALSE.

In pseudocode, the operator ‘^’ represents an exponent, which is the number of times a value
is multiplied by itself. For example, the expression Value2 may be written in pseudocode as
Value ^ 2

Complete the pseudocode for the function IsRA().

FUNCTION IsRA(x1, y1, x2, y2, x3, y3 : INTEGER) RETURNS BOOLEAN

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

ENDFUNCTION
[6]

© UCLES 2024 9618/21/M/J/24 [Turn over


14

(b) The test used to check if a triangle is right-angled can be written in two ways:

A2 = B2 + C2

or

A = √(B2 + C2)

The symbol √ represents the square root operation. For example, √81 = 9

A new function SQRT() is written to perform the square root operation. The function takes an
integer number as a parameter and returns a positive real value representing the square root
of the number.

During testing it is found that the SQRT() function returns a value that is only accurate to
4 decimal places.

For example, SQRT(25) returns 5.0000125 rather than the correct value of 5.0

The function IsRA() from part (a) is modified to use the new SQRT() function to test if a
triangle is right-angled.

Describe a problem that might occur when using the modified IsRA() function and suggest
a solution that still allows the SQRT() function to be used.

Problem ....................................................................................................................................

...................................................................................................................................................

Solution .....................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2024 9618/21/M/J/24


15

BLANK PAGE

© UCLES 2024 9618/21/M/J/24 [Turn over


16

7 A fitness club has a computerised membership system. The fitness club offers a number of
different exercise classes.

The following information is stored for each club member: name, home address, email address,
mobile phone number, date of birth and the exercise(s) they are interested in.

(a) When an exercise class is planned, a new module will send personalised text messages to
each member who has expressed an interest in that exercise. Members wishing to join the
class send a text message back. Members may decide not to receive future text messages
by replying with the message ‘STOP’.

The process of abstraction is used to filter out unnecessary information.

(i) State one advantage of applying abstraction to this problem.

...........................................................................................................................................

..................................................................................................................................... [1]

(ii) Identify three items of information that will be required by the new module.
Justify your choices with reference to the given scenario.

Item 1 required ..................................................................................................................

Justification .......................................................................................................................

...........................................................................................................................................

Item 2 required ..................................................................................................................

Justification .......................................................................................................................

...........................................................................................................................................

Item 3 required ..................................................................................................................

Justification .......................................................................................................................

...........................................................................................................................................
[3]

(iii) Identify two operations that would be required to process data when the new module
receives a text message back from a member.

Operation 1 .......................................................................................................................

...........................................................................................................................................

Operation 2 .......................................................................................................................

...........................................................................................................................................
[2]

© UCLES 2024 9618/21/M/J/24


17

(b) The structure chart illustrates part of the membership program:

Update

A
P2

T1
Name P1

Sub-A Sub-B Sub-C

Data item notes:

• Name contains the name of a club member


• P1 and T1 are of type real.

(i) Explain the meaning of the diamond symbol (labelled with the letter A) in the chart.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) Write the pseudocode module headers for Sub-A and Sub-B.

Sub-A

...........................................................................................................................................

...........................................................................................................................................

Sub-B

...........................................................................................................................................

...........................................................................................................................................
[4]

© UCLES 2024 9618/21/M/J/24 [Turn over


18

8 A teacher is designing a program to process pseudocode projects written by her students.

Each student project is stored in a text file.

The process is split into a number of stages. Each stage performs a different task and creates a
new file named as shown:

File name Comment

MichaelAday_src.txt student project file produced by student Michael Aday

MichaelAday_S1.txt file produced by stage 1

MichaelAday_S2.txt file produced by stage 2

The teacher has defined the first program module as follows:

Module Description
DeleteComment() • called with a parameter of type string representing a line of
pseudocode from a student’s project file
• returns the line after removing any comments

Note on comments:
A comment starts with two forward slash characters and includes all the
remaining characters on the line.

The following example shows a string before and after the comment has
been removed:

Before: IF X2 > 13 THEN //check if limit exceeded


After: IF X2 > 13 THEN

© UCLES 2024 9618/21/M/J/24


19

(a) Complete the pseudocode for module DeleteComment().

FUNCTION DeleteComment(Line : STRING) RETURNS STRING

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

ENDFUNCTION
[8]

© UCLES 2024 9618/21/M/J/24 [Turn over


20

(b) A second module is defined:

Module Description
Stage_1() • called with a parameter of type string representing a student name
• creates a new stage 1 file
• copies each line from the student’s project file to the stage 1 file after
removing any comment from each line
• does not write blank lines to the stage 1 file
• returns the number of lines written to the stage 1 file

Write pseudocode for module Stage_1().

Module DeleteComment() must be used in your solution.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2024 9618/21/M/J/24
21

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [7]

© UCLES 2024 9618/21/M/J/24


22

BLANK PAGE

© UCLES 2024 9618/21/M/J/24


23

BLANK PAGE

© UCLES 2024 9618/21/M/J/24


24

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 2024 9618/21/M/J/24


Cambridge International AS & A Level
* 2 3 2 3 4 6 9 7 5 8 *

COMPUTER SCIENCE 9618/22


Paper 2 Fundamental Problem‑solving and Programming Skills May/June 2024

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 24 pages. Any blank pages are indicated.

DC (PQ/CGW) 329350/3
© UCLES 2024 [Turn over
2

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

1 (a) The following table contains pseudocode examples.

Each example may contain statements that relate to one or more of the following:
• selection
• iteration (repetition)
• input/output.

Complete the table by placing one or more ticks (3) in each row.

Pseudocode example Selection Iteration Input/Output


FOR Index 1 TO 10
Data[Index] 0
NEXT Index
WRITEFILE ThisFile, "****"

UNTIL Level > 25


IF Mark > 74 THEN
READFILE OldFile, Data
ENDIF
[4]

(b) Program variables have data types as follows:

Variable Data type

MyChar CHAR

MyString STRING

MyInt INTEGER

Complete the table by filling in each gap with a function (from the insert) so that each expression
is valid.

Expression

MyInt .......................................... (3.1415926)

MyChar .......................................... ("Elwood", 3, 1)

MyString .......................................... ( .......................................... (27.509))

MyInt .......................................... ( .......................................... ("ABC123", 3))


[4]

© UCLES 2024 9618/22/M/J/24


3

(c) The variables given in part (b) are chosen during the design stage of the program development
life cycle.

The choices are to be documented to simplify program maintenance.

State a suitable way of documenting the variables and give one piece of information that
should be recorded, in addition to the data type.

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2024 9618/22/M/J/24 [Turn over


4

2 A program is being developed.

(a) An algorithm for part of the program will:


• input three numeric values and assign them to identifiers Num1, Num2 and Num3
• assign the largest value to variable Ans
• output a message giving the largest value and the average of the three numeric values.

Assume the values are all different and are input in no particular order.

Complete the program flowchart on page 5 to represent the algorithm.

© UCLES 2024 9618/22/M/J/24


5

START

INPUT Numl, Num2, Num3

No

Yes

END

[5]

© UCLES 2024 9618/22/M/J/24 [Turn over


6

(b) A different part of the program contains an algorithm represented by the following program
flowchart:

START

Set Flag to GetStat()

Is Flag = Yes
TRUE ?

No END

Set Port to 1

No
Is Port = 4 ?

CALL Reset(Port)
Yes

Set Port to Port + 1

Write pseudocode for the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]
© UCLES 2024 9618/22/M/J/24
7

3 A factory needs a program to help manage its production of items.

Data will be stored about each item.

The data for each item will be held in a record structure of type Component.

The programmer has started to define the fields that will be needed as shown in the table.

Field Example value Comment


Item_Num 123478 a numeric value used as an array index
Reject FALSE TRUE if this item has been rejected
Stage 'B' a letter to indicate the stage of production
Limit_1 13.5 any value in the range 0 to 100 inclusive
Limit_2 26.4 any value in the range 0 to 100 inclusive

(a) (i) Write pseudocode to declare the record structure for type Component.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [4]

(ii) A 1D array Item of 2000 elements will store the data for all items.

Write pseudocode to declare the Item array.

...........................................................................................................................................

..................................................................................................................................... [2]

(b) State three benefits of using an array of records to store the data for all items.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................

3 ................................................................................................................................................

...................................................................................................................................................
[3]
© UCLES 2024 9618/22/M/J/24 [Turn over
8

4 A triangle has sides of length A, B and C.

B C

In this example, A is the length of the longest side.

This triangle is said to be right‑angled if the following equation is true:

A × A = (B × B) + (C × C)

A procedure will be written to check whether three lengths represent a right‑angled triangle.
The lengths will be input in any sequence.

The procedure IsRA() will:


• prompt and input three integer values representing the three lengths
• test whether the three lengths correspond to the sides of a right‑angled triangle
• output a suitable message.

The length of the longest side may not be the first value input.

© UCLES 2024 9618/22/M/J/24


9

Write pseudocode for the procedure IsRA().

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [5]

© UCLES 2024 9618/22/M/J/24 [Turn over


10

5 A program is being designed in pseudocode.

The program contains a global 1D array Data of type string containing 200 elements.

The first element has the index value 1.

A procedure Process() is written to initialise the values in the array:

PROCEDURE Process(Label : STRING)


DECLARE Index : INTEGER
Index 0
INPUT Data[Index]
WHILE Index < 200
Index Index + 1
CASE OF (Index MOD 2)
0 : Data[Index] TO_UPPER(Label)
1 : Data[Index] TO_LOWER(Label)
OTHERWISE : OUTPUT "Alarm 1201"
ENDCASE
NEXT Index
OUTPUT "Completed " & Index & " times"
ENDPROCEDURE

(a) (i) The pseudocode contains two syntax errors and one other error.

Identify the errors.

Syntax error 1 ....................................................................................................................

...........................................................................................................................................

Syntax error 2 ....................................................................................................................

...........................................................................................................................................

Other error .........................................................................................................................

...........................................................................................................................................
[3]

(ii) The procedure contains a statement that is not needed.

Identify the pseudocode statement and explain why it is not needed.

Statement ..........................................................................................................................

Explanation .......................................................................................................................

...........................................................................................................................................
[2]

© UCLES 2024 9618/22/M/J/24


11

(b) After correcting all syntax errors, the pseudocode is translated into program code which
compiles without generating any errors.

When the program is executed it unexpectedly stops responding.

Identify the type of error that has occurred.

............................................................................................................................................. [1]

© UCLES 2024 9618/22/M/J/24 [Turn over


12

6 A music player stores music in a digital form and has a display which shows the track being
played.

(a) Up to 16 characters can be displayed. Track titles longer than 16 characters will need to be
trimmed as follows:
• Words must be removed from the end of the track title until the resulting title is less than
14 characters.
• When a word is removed, the space in front of that word is also removed.
• Three dots are added to the end of the last word displayed when one or more words
have been removed.

The table below shows some examples:

Original title Display string

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Bat out of Hull B a t o u t o f H u l l

Bohemian Symphony B o h e m i a n . . .

Paperbook Writer P a p e r b o o k W r i t e r

Chris Sings the Blues C h r i s S i n g s . . .

Green Home Alabama G r e e n H o m e . . .

A function Trim() will:


• take a string representing the original title
• return the string to be displayed.

Assume:
• Words in the original title are separated by a single space character.
• There are no spaces before the first word or after the last word of the original title.
• The first word of the original title is less than 14 characters.

© UCLES 2024 9618/22/M/J/24


13

Write pseudocode for the function Trim().

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [7]

© UCLES 2024 9618/22/M/J/24 [Turn over


14

(b) Music is stored as a sequence of digital samples.

Each digital sample is a denary value in the range 0 to 99999999 (8 digits).

The samples are to be stored in a text file. Each sample is converted to a numeric string and
32 samples are concatenated (joined) to form a single line of the text file.

Each numeric string is 8 characters in length; leading ‘0’ characters are added as required.

Example:

Sample Denary value String


1 456 "00000456"
2 48 "00000048"
3 37652 "00037652"

32 673 "00000673"

The example samples will be stored in the text file as a single line:

"000004560000004800037652...00000673"

(i) Identify one drawback of adding leading ‘0’ characters to each numeric string.

...........................................................................................................................................

..................................................................................................................................... [1]

(ii) Suggest an alternative method of storing the samples which does not involve adding
leading ‘0’ characters but which would still allow each individual sample to be extracted.

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [1]

(iii) State one drawback of the alternative method given in part (b)(ii).

...........................................................................................................................................

..................................................................................................................................... [1]

© UCLES 2024 9618/22/M/J/24


15

BLANK PAGE

© UCLES 2024 9618/22/M/J/24 [Turn over


16

7 A fitness club has a computerised membership system.

The system stores information for each club member: name, home address, email address, mobile
phone number, date of birth and exercise preferences.

Many classes are full, and the club creates a waiting list for each class. The club adds details of
members who want to join a class that is full to the waiting list for that class.

When the system identifies that a space is available in one of the classes, a new module will send
a text message to each member who is on the waiting list.

(a) Decomposition will be used to break the new module into sub‑modules (sub‑problems).

Identify three sub‑modules that could be used in the design and describe their use.

Sub‑module 1 ...........................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Sub‑module 2 ...........................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Sub‑module 3 ...........................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[3]

© UCLES 2024 9618/22/M/J/24


17

(b) A different part of the program is represented by the following state‑transition diagram.

Input-B | Output-W
Input-B
Input-B
START
S1 S3 S2 S5

Input-A
Input-A Input-A | Output-W

Input-B | Output-Y
Input-A | Output-X
S4

(i) Complete the table to show the inputs, outputs and next states.

Assume that the current state for each row is given by the ‘Next state’ on the previous
row. For example, the first Input‑A is made when in state S1.

If there is no output for a given transition, then the output cell should contain ‘none’.

The first two rows have been completed.

Input Output Next state

S1

Input‑A none S3

Output‑W

none

Input‑B

Input‑A

S4
[5]

(ii) Identify the input sequence that will cause the minimum number of state changes in the
transition from S1 to S4.

..................................................................................................................................... [1]

© UCLES 2024 9618/22/M/J/24 [Turn over


18

8 A teacher is designing a program to process pseudocode projects written by her students.

Each student project is stored in a text file.

The process is split into a number of stages. Each stage performs a different task and creates a
new file.

For example:

File name Comment

MichaelAday_src.txt Student project file produced by student Michael Aday

MichaelAday_S1.txt File produced by stage 1

MichaelAday_S2.txt File produced by stage 2

(a) Suggest a reason why the teacher’s program has been split into a number of stages and give
the benefit of producing a different file from each stage.

Reason .....................................................................................................................................

...................................................................................................................................................

Benefit ......................................................................................................................................

...................................................................................................................................................
[2]

(b) The teacher has defined the first program module as follows:

Module Description
DeleteSpaces() • called with a parameter of type string representing a line of
pseudocode from a student’s project file
• returns the line after removing any leading space characters

The following example shows a string before and after the leading
spaces have been removed:

Before: " IF X2 > 13 THEN"


After: "IF X2 > 13 THEN"

© UCLES 2024 9618/22/M/J/24


19

Complete the pseudocode for module DeleteSpaces().

FUNCTION DeleteSpaces(Line : STRING) RETURNS STRING

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

ENDFUNCTION [6]

© UCLES 2024 9618/22/M/J/24 [Turn over


20

(c) Two modules are defined:

Module Description
DeleteComment() • called with a parameter of type string representing a line of
(already written) pseudocode from a student’s project file
• returns the line after removing any comment
Stage_2() • called with two parameters:
○ a string representing an input file name
○ a string representing an output file name
• copies each line from the input file to the existing output file having
first removed all leading spaces and comments from that line
• does not write blank lines to the output file
• outputs a final message giving the number of blank lines removed

© UCLES 2024 9618/22/M/J/24


21

Write pseudocode for module Stage_2().

Modules DeleteComment() and DeleteSpaces() must be used in your solution.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [8]

© UCLES 2024 9618/22/M/J/24


22

BLANK PAGE

© UCLES 2024 9618/22/M/J/24


23

BLANK PAGE

© UCLES 2024 9618/22/M/J/24


24

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 2024 9618/22/M/J/24


* 0019655333801 *

,  ,

Cambridge International AS & A Level

¬OŠ> 3mGwMq=ž5uUpW
¬–šbD§43Pt|€¤P\M‚
¥u¥U5U¥5UEU•e•EeEU
* 6 8 0 6 8 0 7 8 2 2 *

COMPUTER SCIENCE 9618/23


Paper 2 Fundamental Problem-solving and Programming Skills May/June 2024

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 24 pages. Any blank pages are indicated.

DC (KS/CGW) 329352/4
© UCLES 2024 [Turn over
* 0019655333802 *

DO NOT WRITE IN THIS MARGIN


2
,  ,

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

1 A program uses many complex algorithms.

One algorithm is repeated in several places. The code for the algorithm is the same wherever it is
used, but the calculations within the algorithm may operate on different data.

The result of each calculation is used by the code that follows it.

It is decided to modify the program and implement the algorithm as a separate module.

DO NOT WRITE IN THIS MARGIN


(a) (i) State two benefits of this modification to the existing program.

1 ........................................................................................................................................

...........................................................................................................................................

2 ........................................................................................................................................

...........................................................................................................................................
[2]

(ii) Describe how the modification would be implemented.

DO NOT WRITE IN THIS MARGIN


...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

DO NOT WRITE IN THIS MARGIN


...........................................................................................................................................

..................................................................................................................................... [3]
DO NOT WRITE IN THIS MARGIN

ĬÍĊ¾Ġ³íÇ÷Íñ½Ğ¸÷×î×
© UCLES 2024 ĬĖĜáÁģ¸ÕçýþģÜõĠĤÕĂ
ĥåõÕõµåÕĥąąÕåÕåĥĥÕ
9618/23/M/J/24
* 0019655333803 *
DO NOT WRITE IN THIS MARGIN

3
,  ,

(b) Four of the expressions used in the program are represented by pseudocode in the table.

Complete each pseudocode expression with a function or operator so that it evaluates to the
value shown.

Any functions and operators used must be defined in the insert.

Pseudocode expression Evaluates to

"and"
DO NOT WRITE IN THIS MARGIN

........................................ ("Random", 2, 3)

15
5 + ........................................ (10/11/2023)

TRUE
........................................ ("45000")

(20 ........................................ 3) + 1 3

[4]
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN

ĬÏĊ¾Ġ³íÇ÷Íñ½Ğ¸õ×î×
© UCLES 2024 ĬĖěâÉĥ¼åÒûóæĀý¼ĤåĂ
ĥåąĕµÕŵõõÕÕåµÅåõÕ
9618/23/M/J/24 [Turn over
* 0019655333804 *

DO NOT WRITE IN THIS MARGIN


4
,  ,

2 (a) A program uses a global 1D array of type string and a text file.

An algorithm that forms part of the program is expressed as follows:


• copy the first line from the file into the first element of the array
• copy the second line from the file into the second element of the array
• continue until all lines in the file have been copied into the array.

Stepwise refinement is applied to the algorithm.

Outline five steps for this algorithm that could be used to produce pseudocode.

DO NOT WRITE IN THIS MARGIN


Assume there are more elements in the array than lines in the file.

Do not use pseudocode statements in your answer.

Step 1 .......................................................................................................................................

...................................................................................................................................................

Step 2 .......................................................................................................................................

...................................................................................................................................................

DO NOT WRITE IN THIS MARGIN


Step 3 .......................................................................................................................................

...................................................................................................................................................

Step 4 .......................................................................................................................................

...................................................................................................................................................

Step 5 .......................................................................................................................................

...................................................................................................................................................
[5]

DO NOT WRITE IN THIS MARGIN


(b) Sequence is one programming construct.

Identify one other programming construct that will be required when the algorithm from
part (a) is converted into pseudocode and explain its use.

Construct ..................................................................................................................................

...................................................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................
[2]
DO NOT WRITE IN THIS MARGIN

ĬÍĊ¾Ġ³íÇ÷Íñ½Ğ¶÷×ð×
© UCLES 2024 ĬĖěãÉğÊäåõüÝÞáĚôÍĂ
ĥĕÕĕõÕÅĕĕÕåÕĥµĥåĥÕ
9618/23/M/J/24
DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN

,

© UCLES 2024
* 0019655333805 *

ĥĕåÕµµåõąåõÕĥÕąĥõÕ
ĬĖĜäÁĩÆÔÔăąĬúÙ¾ôÝĂ
ĬÏĊ¾Ġ³íÇ÷Íñ½Ğ¶õ×ð×

,
5

9618/23/M/J/24
BLANK PAGE

[Turn over
* 0019655333806 *

DO NOT WRITE IN THIS MARGIN


6
,  ,

3 A record structure is declared to hold data relating to components being produced in a factory:

TYPE Component
DECLARE Item_ID : STRING
DECLARE Reject : BOOLEAN
DECLARE Weight : REAL
ENDTYPE

The factory normally produces a batch (or set) of 1000 components at a time. A global array is
declared to store 1000 records for a batch:

DO NOT WRITE IN THIS MARGIN


DECLARE Batch : ARRAY [1:1000] OF Component

Two global variables contain the minimum and maximum acceptable weight for each component.
The values represent an inclusive range and are declared as:

DECLARE Min, Max : REAL

(a) (i) A program uses a variable ThisIndex as the array index to access a record.

Write a pseudocode clause to check whether or not the weight of an individual component
is within the acceptable range.

DO NOT WRITE IN THIS MARGIN


...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

(ii) When batches of less than 1000 components are processed, it is necessary to indicate
that certain elements in the array are unused.

Suggest how an unused array element could be indicated.

...........................................................................................................................................

DO NOT WRITE IN THIS MARGIN


..................................................................................................................................... [1]

(b) A module InRange() will:


• be called with an integer parameter representing an index value of a record in the Batch
array
• check if the weight of the indexed component is within the acceptable range
• return TRUE if the weight is in the range and FALSE if it is not.

A module BatchCheck() will:


• iterate through a batch of 1000 component records
• call module InRange() to check each individual component record
• keep a count of the number of components that fail
• output a suitable warning message and immediately stop if the number of failed
DO NOT WRITE IN THIS MARGIN

components exceeds 5.

ĬÑĊ¾Ġ³íÇ÷Íñ½Ğ·õÖî×
© UCLES 2024 ĬĖěä¾ģÞÚÜĈøđĚáßÜÍĂ
ĥÅąÕµĕåÕÅÅÕÕåÕåååÕ
9618/23/M/J/24
* 0019655333807 *
DO NOT WRITE IN THIS MARGIN

7
,  ,

Complete the program flowchart to represent the algorithm for module BatchCheck().

START
DO NOT WRITE IN THIS MARGIN

Is
Index = 1001 ?
DO NOT WRITE IN THIS MARGIN

Yes

No
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN

END

[5]
ĬÓĊ¾Ġ³íÇ÷Íñ½Ğ·÷Öî×
© UCLES 2024 ĬĖĜãÆĥâêÝòĉؾÙûÜÝĂ
ĥÅõĕõõŵյąÕåµÅĥµÕ
9618/23/M/J/24 [Turn over
* 0019655333808 *

DO NOT WRITE IN THIS MARGIN


8
,   ,

4 A procedure TwoParts() will input a sequence of real values, one at a time.

The procedure will:


• process the sequence in two parts
• form a first total by adding the values until the first zero
• form a second total by adding the values after the first zero until the second zero
• output the average of the two totals, together with a suitable message.

Values input in the first part are totalled using global variable TotalA and those input in the
second part are totalled using global variable TotalB.

DO NOT WRITE IN THIS MARGIN


(a) Write pseudocode for the procedure TwoParts().

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

DO NOT WRITE IN THIS MARGIN


...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

DO NOT WRITE IN THIS MARGIN


...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

ĬÑĊ¾Ġ³íÇ÷Íñ½ĞµõÖð×
© UCLES 2024 ĬĖĜâÆğÔßÚðĂÏĠõÙÌÕĂ
ĥõåĕµõÅĕµĕõÕĥµĥĥåÕ
9618/23/M/J/24
* 0019655333809 *
DO NOT WRITE IN THIS MARGIN

9
,   ,

(b) The value zero denotes the split between the two parts of the sequence.

The requirement changes and now there may be up to 20 parts.

(i) Identify a suitable data structure that could be used to store the different total values.

..................................................................................................................................... [2]

(ii) Describe three benefits of using the data structure given in part (b)(i).

1 ........................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...........................................................................................................................................

2 ........................................................................................................................................

...........................................................................................................................................

3 ........................................................................................................................................

...........................................................................................................................................
[3]
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN

ĬÓĊ¾Ġ³íÇ÷Íñ½Ğµ÷Öð×
© UCLES 2024 ĬĖěá¾ĩÐÏßĊïĚ¼ýýÌåĂ
ĥõÕÕõĕåõåĥåÕĥÕąåµÕ
9618/23/M/J/24 [Turn over
* 0019655333810 *

DO NOT WRITE IN THIS MARGIN


10
,  ,

5 A program is being designed in pseudocode.

The program contains the following declaration:

DECLARE Data : ARRAY[1:1000] OF STRING

A procedure ArrayInitialise() is written to initialise the values in the array:

PROCEDURE ArrayInitialise(Label : STRING)


DECLARE Index : INTEGER
Index 1

DO NOT WRITE IN THIS MARGIN


WHILE Index <= 1000
CASE OF (Index MOD 2)
0 : Data[Index] FormatA(Label)
Index Index + 1
1 : Data[Index] FormatB(Label)
Index Index + 1
ENDCASE
ENDWHILE
ENDPROCEDURE

Functions FormatA() and FormatB() apply fixed format case changes to the parameter string.

DO NOT WRITE IN THIS MARGIN


(a) The design of the procedure does not use the most appropriate loop construct.

Suggest a more appropriate construct that could be used and explain your choice.

Construct ..................................................................................................................................

Explanation ...............................................................................................................................

...................................................................................................................................................
[2]

(b) The algorithm calls one of the functions FormatA() and FormatB() each time within the
loop.

DO NOT WRITE IN THIS MARGIN


Explain why this is not efficient and suggest a more efficient solution.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

ĬÑĊ¾Ġ³íÇ÷Íñ½Ğ¸õØî×
© UCLES 2024 ĬĖęâ¿ĝܹØ÷ĉõĄ÷­ôÝĂ
ĥåÅÕµõĥĕĕåõĕĥĕĥĥĕÕ
9618/23/M/J/24
DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN

,

© UCLES 2024
* 0019655333811 *

ĥåµĕõĕąõąÕåĕĥõąåąÕ
ĬĖĚáÇīØÉáāø´ØÿĩôÍĂ
ĬÓĊ¾Ġ³íÇ÷Íñ½Ğ¸÷Øî×

,
11

9618/23/M/J/24
BLANK PAGE

[Turn over
* 0019655333812 *

DO NOT WRITE IN THIS MARGIN


12
,  ,

6 A program displays a progress bar to inform the user of the progress of tasks that take a significant
time to complete, such as those involving file transfer operations.

Task progress is divided into 11 steps. Each step represents the amount of progress as a
percentage. An image is associated with each step and each image is stored in a different file.

Different progress bar images may be selected. For a given image, files all have the same filename
root, with a different suffix.

The table illustrates the process for using the image with filename root BargraphA

DO NOT WRITE IN THIS MARGIN


Percentage
Step Image filename Image
progress
1 < 10 BargraphA-1.bmp
2 >= 10 and < 20 BargraphA-2.bmp
3 >= 20 and < 30 BargraphA-3.bmp

9 >= 80 and < 90 BargraphA-9.bmp

DO NOT WRITE IN THIS MARGIN


10 >= 90 and < 100 BargraphA-10.bmp
11 100 BargraphA-11.bmp

A procedure Progress() will:


• be called with two parameters:
○ an integer representing the percentage progress (0 to 100 inclusive)
○ a string representing the image filename root
• generate the full image filename
• call a procedure Display() using the full image filename as the parameter.

DO NOT WRITE IN THIS MARGIN


DO NOT WRITE IN THIS MARGIN

ĬÑĊ¾Ġ³íÇ÷Íñ½Ğ¶õØð×
© UCLES 2024 ĬĖĚäÇġæÀÖÿï»öãËĤåĂ
ĥĕĥĕµĕąÕĥõÕĕåõååĕÕ
9618/23/M/J/24
* 0019655333913 *
DO NOT WRITE IN THIS MARGIN

13
,  ,

(a) Write pseudocode for procedure Progress().

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

............................................................................................................................................. [6]

ĬÓĉ¿Ġ³íÇ÷Íñ½ĞµõØð×
© UCLES 2024 ĬĖĚâÌĞÕêåþă½ģËÔÍĂ
ĥåÅÕµµåµąõõĕĥµåĥåÕ
9618/23/M/J/24 [Turn over
* 0019655333914 *

DO NOT WRITE IN THIS MARGIN


14
,  ,

(b) The definition of procedure Progress() is provided here for reference:

A procedure Progress() will:


• be called with two parameters:
○ an integer representing the percentage progress (0 to 100 inclusive)
○ a string representing the image filename root
• generate the full image filename
• call a procedure Display() using the full image filename as the parameter.

DO NOT WRITE IN THIS MARGIN


Progress() will be rewritten and a new module Progress2() produced with these
requirements:
• an additional parameter of type integer will specify the total number of steps
• the image filename will be returned (procedure Display() will not be called from within
Progress2()).

(i) Write pseudocode for the new module header.

...........................................................................................................................................

...........................................................................................................................................

DO NOT WRITE IN THIS MARGIN


..................................................................................................................................... [2]

(ii) State one benefit of increasing the number of steps.

...........................................................................................................................................

..................................................................................................................................... [1]

DO NOT WRITE IN THIS MARGIN


DO NOT WRITE IN THIS MARGIN

ĬÍĉ¿Ġ³íÇ÷Íñ½Ğ¶öÕò×
© UCLES 2024 ĬĖęäÉĤêÒ×ČĈãġº¿ĤÕĂ
ĥąÅĕõÕĥĕĥĥõÕåõąåõÕ
9618/23/M/J/24
DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN

,

© UCLES 2024
* 0019655333915 *

ĥąµÕµµąõõĕåÕåĕĥĥĥÕ
ĬĖĚãÁĦæââîùĦµÂěĤåĂ
ĬÏĉ¿Ġ³íÇ÷Íñ½Ğ¶øÕò×

,
15

9618/23/M/J/24
BLANK PAGE

[Turn over
* 0019655333916 *

DO NOT WRITE IN THIS MARGIN


16
,  ,

7 Seven program modules form part of a program. A description of the relationship between the
modules is summarised below. Any return values are stated in the description.

Module name Description

Mod-A calls Mod-B followed by Mod-C

• called with parameters Par1 and Par2


Mod-B • calls either Mod-D or Mod-E, determined when the program runs
• returns a Boolean value

DO NOT WRITE IN THIS MARGIN


• called with parameters Par1 and Par3
Mod-C • Par3 is passed by reference
• repeatedly calls Mod-F followed by Mod-G

Mod-D called with parameter Par2

• called with parameter Par3


Mod-E
• returns an integer value

Mod-F called with parameter Par3

• called with parameter Par3


Mod-G
• Par3 is passed by reference

DO NOT WRITE IN THIS MARGIN


Parameters in the table are as follows:
• Par1 and Par3 are of type string.
• Par2 is of type integer.

(a) (i) Identify the modules that would be implemented as functions.

..................................................................................................................................... [1]

(ii) Modules Mod-F and Mod-G are both called with Par3 as a parameter.
In the case of Mod-F, the parameter is passed by value.
In the case of Mod-G, the parameter is passed by reference.

DO NOT WRITE IN THIS MARGIN


Explain the effect of the two different ways of passing the parameter Par3.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]
DO NOT WRITE IN THIS MARGIN

ĬÍĉ¿Ġ³íÇ÷Íñ½Ğ¸öÕô×
© UCLES 2024 ĬĖĚâÁĠØçÕôòĝėйôÍĂ
ĥµĥÕõµąÕĕµÕÕĥĕÅĥõÕ
9618/23/M/J/24
* 0019655333917 *
DO NOT WRITE IN THIS MARGIN

17
,  ,

(b) Draw a structure chart to show the relationship between the seven modules and the
parameters passed between them.
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN

[6]
ĬÏĉ¿Ġ³íÇ÷Íñ½Ğ¸øÕô×
© UCLES 2024 ĬĖęáÉĪÜ×äĆÿìÃĖĝôÝĂ
ĥµĕĕµÕĥµąÅąÕĥõååĥÕ
9618/23/M/J/24 [Turn over
* 0019655333918 *

DO NOT WRITE IN THIS MARGIN


18
,   ,

8 A teacher is designing a program to process pseudocode projects written by her students.

The program analyses a student project and extracts information about each module that is
defined (each procedure or function). This information is stored in a global 2D array ModInfo of
type string.

A module header is the first line of a module definition and starts with either of the keywords
PROCEDURE or FUNCTION.

An example of part of the array is given below. Row 10 of the array shows that a procedure header
occurs on line 27 and row 11 shows that a function header occurs on line 35. "P" represents a

DO NOT WRITE IN THIS MARGIN


procedure and "F" represents a function:

x = 1 x = 2 x = 3

ModInfo[10, x] "27" "P" "MyProc(Z : CHAR)"

ModInfo[11, x] "35" "F" "MyFun(Y : CHAR) RETURNS BOOLEAN"

The string stored in column 3 is called the module description. This is the module header without
the keyword.

A valid module header will:

DO NOT WRITE IN THIS MARGIN


• be at least 13 characters long
• start with the keyword PROCEDURE or FUNCTION. The keyword may appear in either upper or
lower case (or a mix of both) and must be followed by a space character.

The teacher has defined the first program module as follows:

Module Description
Header() • called with a parameter of type string representing a line of
pseudocode
• if the line is a valid procedure header, returns a string:
"P<Module description>"

DO NOT WRITE IN THIS MARGIN


• if the line is a valid function header, returns a string:
"F<Module description>"
• otherwise, returns an empty string

For example, given the string:

"FUNCTION Zap(X : INTEGER) RETURNS CHAR"

Header()returns the string:

"FZap(X : INTEGER) RETURNS CHAR"


DO NOT WRITE IN THIS MARGIN

ĬÍĉ¿Ġ³íÇ÷Íñ½Ğµö×ò×
© UCLES 2024 ĬĖěâÌĞбÛûùÇûĠÍÌåĂ
ĥĥąĕõµåÕµąÕĕĥµÅĥÅÕ
9618/23/M/J/24
* 0019655333919 *
DO NOT WRITE IN THIS MARGIN

19
,   ,

(a) Write pseudocode for module Header().

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [7]
DO NOT WRITE IN THIS MARGIN

ĬÏĉ¿Ġ³íÇ÷Íñ½Ğµø×ò×
© UCLES 2024 ĬĖĜáÄĬÔÁÞýĈĂßĘĉÌÕĂ
ĥĥõÕµÕŵåõąĕĥÕååÕÕ
9618/23/M/J/24 [Turn over
* 0019655333920 *

DO NOT WRITE IN THIS MARGIN


20
,  ,

(b) A new module is required:

Module Description
FindModules() • called with a parameter of type string representing a student
project file name
• uses module Header() to check each line of the project
• assigns values to the ModInfo array for each module
declaration in the student project

As a reminder, the previous example of part of the array is repeated below:

DO NOT WRITE IN THIS MARGIN


x = 1 x = 2 x = 3
ModInfo[10, x] "27" "P" "MyProc(Z : CHAR)"
ModInfo[11, x] "35" "F" "MyFun(Y : CHAR) RETURNS BOOLEAN"

Write pseudocode for module FindModules().

Assume that the array contains enough rows for the number of modules in each project.

...................................................................................................................................................

DO NOT WRITE IN THIS MARGIN


...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

DO NOT WRITE IN THIS MARGIN


...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

ĬÍĉ¿Ġ³íÇ÷Íñ½Ğ·ö×ô×
© UCLES 2024 ĬĖĜäÄĢâÈÙăÿĉý¼ëÜÝĂ
ĥÕåÕõÕÅĕÅÕõĕåÕąåÅÕ
9618/23/M/J/24
* 0019655333921 *
DO NOT WRITE IN THIS MARGIN

21
,  ,

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [8]
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN

ĬÏĉ¿Ġ³íÇ÷Íñ½Ğ·ø×ô×
© UCLES 2024 ĬĖěãÌĨÞ¸àõòÀÙÄïÜÍĂ
ĥÕÕĕµµåõÕååĕåµĥĥÕÕ
9618/23/M/J/24
,

© UCLES 2024
* 0019655333922 *

ĥąõĕµĕåÕĕÅąĕĥµÅåąÕ
ĬĖĜãÇĞÆ®èòăµ¹¼ĎôÝĂ
ĬÑĉ¿Ġ³íÇ÷Íñ½Ğ¶øÖò×

,
22

9618/23/M/J/24
BLANK PAGE

DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN

,

© UCLES 2024
* 0019655333923 *

ĥąąÕõõŵąµÕĕĥÕåĥĕÕ
ĬĖěä¿ĬʾÑĈîôĝÄÊôÍĂ
ĬÓĉ¿Ġ³íÇ÷Íñ½Ğ¶öÖò×

,
23

9618/23/M/J/24
BLANK PAGE
* 0019655333924 *

DO NOT WRITE IN THIS MARGIN


24
,  ,

BLANK PAGE

DO NOT WRITE IN THIS MARGIN


DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN

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 2024 ĬĖěá¿Ģ¼ËæĊõû¿ĠĬĤåĂ
ĥµÕÕµõÅĕĥĕåĕåÕąĥąÕ
9618/23/M/J/24
Cambridge International AS & A Level
* 6 2 8 1 0 3 5 9 0 4 *

COMPUTER SCIENCE 9618/31


Paper 3 Advanced Theory May/June 2024

1 hour 30 minutes

You must answer on the question paper.

No additional materials are needed.

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.

This document has 12 pages. Any blank pages are indicated.

DC (PQ) 341261
© UCLES 2024 [Turn over
2

1 Real numbers are stored in a computer system using floating-point representation with:

• 10 bits for the mantissa


• 6 bits for the exponent
• two’s complement form for both the mantissa and the exponent.

(a) Calculate the denary value of the given normalised floating-point number.

Show your working.

Mantissa Exponent

0 1 0 0 1 1 1 1 0 0 0 0 1 0 0 1

Working .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Answer ......................................................................................................................................
[3]

(b) Calculate the normalised floating-point representation of –102.75 in this system.

Show your working.

Mantissa Exponent

Working .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[3]

© UCLES 2024 9618/31/M/J/24


3

2 The TCP / IP protocol suite has four layers:

Transport, Application, Link, Internet

(a) Complete the diagram to show the correct order for these layers.

[2]

(b) Describe the function of the Transport layer.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) Outline one protocol that is associated with the Application layer.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

3 (a) Explain what is meant by non-composite and composite data types.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2024 9618/31/M/J/24 [Turn over


4

(b) Write pseudocode statements to declare the record data type FootballClub to hold data
about football clubs in a league, to include:

• name of team
• date team joined the league
• main telephone number
• name of the manager
• number of members
• current position in the league.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

4 (a) Describe the sequential method of file access.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Explain how the sequential method of file access is applied to files with serial organisation
and to files with sequential organisation.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2024 9618/31/M/J/24


5

5 (a) Write this Reverse Polish Notation (RPN) in infix form:

5 2 + 9 3 - / 3 *

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(b) Write this infix expression in RPN:

((7 + 3) - (2 * 8)) / 6

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) Evaluate this RPN expression:

a b - c d + * e /

when

a = 17, b = 5, c = 7, d = 3 and e = 10

Show the changing contents of the stack as the RPN expression is evaluated.

[4]

© UCLES 2024 9618/31/M/J/24 [Turn over


6

6 The diagram shows a logic circuit.

A Q

P R
B Z

(a) Complete the truth table for the given logic circuit.

Show your working.

Working space
A B C P Q R S Z

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1
[3]

(b) Write the Boolean expression that corresponds to the logic circuit as a sum-of-products.

Z = ............................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2024 9618/31/M/J/24


7

(c) (i) Complete the Karnaugh map (K-map) for the Boolean expression:

A.B.C + A.B.C + A.B.C + A.B.C + A.B.C + A.B.C

BC
00 01 11 10
A

[2]

(ii) Draw loop(s) around appropriate group(s) in the K-map to produce an optimal
sum-of-products. [2]

(iii) Write the Boolean expression from your answer to part (c)(ii) as a simplified
sum-of-products.

...........................................................................................................................................

..................................................................................................................................... [1]

7 (a) Describe what is meant by a digital certificate.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(b) Explain the role of a digital certificate in creating a digital signature.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2024 9618/31/M/J/24 [Turn over


8

8 A declarative programming language is used to represent the features that are available and the
features that are unavailable on different body styles of a car.

01 feature(sunroof).
02 feature(automatic_tailgate).
03 feature(heated_seats).
04 feature(extra_seats).
05 feature(reversing_camera).
06 feature(dashboard_camera).
07 feature(air_conditioning).
08 feature(heated_windscreen).
09 feature(satnav).
10 bodystyle(saloon).
11 bodystyle(hatchback).
12 bodystyle(estate).
13 bodystyle(minivan).
14 bodystyle(convertible).
15 available(sunroof, hatchback).
16 available(sunroof, minivan).
17 available(reversing_camera, hatchback).
18 available(extra_seats, minivan).
19 available(reversing_camera, saloon).
20 unavailable(sunroof, convertible).
21 unavailable(automatic_tailgate, saloon).
22 unavailable(extra_seats, hatchback).

These clauses have the meanings:

Clause Meaning
01 Sunroof is a feature.
10 Saloon is a body style.
15 Sunroof is available on a hatchback.
20 Sunroof is unavailable on a convertible.

(a) Sliding doors is a feature that is available on a minivan but unavailable on a hatchback.

Write additional clauses to represent this information.

23 .............................................................................................................................................

24 .............................................................................................................................................

25 .............................................................................................................................................
[3]

© UCLES 2024 9618/31/M/J/24


9

(b) Using the variable Options, the goal:

available(Options, saloon)

returns

Options = reversing_camera

Write the result returned by the goal:

available(Options, hatchback)

Options = ........................................................................................................................ [1]

(c) F may be available for B if F is a feature and B is a body style and F is not unavailable for that
body style.

Write this as a rule:

may_choose_option(F, B)

IF .............................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

9 Explain what is meant by Deep Learning in relation to Artificial Intelligence (AI).

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [3]

© UCLES 2024 9618/31/M/J/24 [Turn over


10

10 (a) State a condition that must be true for an array to be searchable for a binary search.

...................................................................................................................................................

............................................................................................................................................. [1]

(b) Complete the given pseudocode to find an item in a 1D array Names of type STRING using a
binary search.

DECLARE Names : ARRAY[1:100000] OF STRING


DECLARE TopOfList : INTEGER
DECLARE EndOfList : INTEGER
DECLARE CurrentItem : INTEGER
DECLARE ToFind : STRING
DECLARE Found : BOOLEAN
DECLARE NotInList : BOOLEAN
TopOfList 1 ←
EndOfList 100000 ←
OUTPUT "Which name do you wish to find? "
INPUT ToFind

...................................................................................................................................................

NotInList ← FALSE
WHILE ................................................ AND ................................................
CurrentItem ←
(TopOfList + EndOfList) DIV 2

IF ........................................................................................................... THEN
Found ← TRUE
ELSE
IF TopOfList >= EndOfList THEN

...........................................................................................................
ELSE
IF ToFind > Names[CurrentItem] THEN

...........................................................................................................
ELSE
EndOfList ←
CurrentItem – 1
ENDIF
ENDIF
ENDIF
ENDWHILE
IF Found = TRUE THEN
OUTPUT "Item found at position ", CurrentItem, " in array"
ELSE
OUTPUT "Item not in array"
ENDIF
[5]

© UCLES 2024 9618/31/M/J/24


11

(c) Describe the performance of a binary search in relation to the number of data items in the
array being searched. Refer to Big O notation in your answer.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

11 Reduced Instruction Set Computers (RISC) and Complex Instruction Set Computers (CISC) are
two types of processor.

(a) State two features of RISC processors.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Outline the process of interrupt handling as it could be applied to RISC or CISC processors.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Explain how pipelining affects interrupt handling for RISC processors.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2024 9618/31/M/J/24


12

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 2024 9618/31/M/J/24


Cambridge International AS & A Level
* 4 9 7 1 7 0 3 6 1 7 *

COMPUTER SCIENCE 9618/32


Paper 3 Advanced Theory May/June 2024

1 hour 30 minutes

You must answer on the question paper.

No additional materials are needed.

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.

This document has 12 pages.

DC (DE) 352034/4
© UCLES 2024 [Turn over
2

1 (a) Describe the effect of changing the allocation of bits used for the mantissa and for the
exponent in a floating-point number with a fixed total number of bits.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Real numbers are stored in a computer, using floating-point representation with:

• 12 bits for the mantissa


• 4 bits for the exponent
• two’s complement form for both the mantissa and exponent.

Calculate the normalised floating-point representation of +54.8125 in this system.

Show your working.

Mantissa Exponent

Working .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2024 9618/32/M/J/24


3

2 (a) Outline why protocols are essential for communication between computers.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) State the names of two different protocols associated with the sending and receiving of
emails between computers.

Sending ....................................................................................................................................

Receiving ..................................................................................................................................
[2]

(c) Explain the meaning of the phrase:

BitTorrent protocol provides peer-to-peer file sharing.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2024 9618/32/M/J/24 [Turn over


4

3 (a) Explain what is meant by the term non-composite data type and give an example of a
non-composite data type.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Example ....................................................................................................................................
[3]

(b) Write pseudocode statements to declare the set data type EvenNumbers to hold this set of
even numbers between 2 and 12:

2, 4, 6, 8, 10, 12

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2024 9618/32/M/J/24


5

4 Sheila has a customer called Fred. Fred wants to send Sheila a confidential document as part of a
transaction.

Explain how Fred uses asymmetric encryption to send his document securely.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [4]

© UCLES 2024 9618/32/M/J/24 [Turn over


6

5 (a) Write this infix expression in Reverse Polish Notation (RPN):

(7 – 2 + 8) / (9 – 5)

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Evaluate this RPN expression:

a d + a b + c - *

when

a = 6, b = 3, c = 7 and d = 9

Show the changing contents of the stack as the RPN expression is evaluated.

[4]

(c) Write this RPN expression in infix form:

b a c - + d b + * c /

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2024 9618/32/M/J/24


7

6 The diagram shows a logic circuit.

P
A
S

Q
B Z

T
R
C

(a) Complete the truth table for the given logic circuit.
Show your working.

Working space
A B C P Q R S T Z
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
[3]

(b) Write the Boolean expression that corresponds to the logic circuit as a sum-of-products.

Z = ............................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2024 9618/32/M/J/24 [Turn over


8

(c) (i) Complete the Karnaugh map (K-map) for this Boolean expression:
–– – – – – –– –
A.B.C + A.B.C + A.B.C + A.B.C + A.B.C + A.B.C

BC
A 00 01 11 10

[2]

(ii) Draw loop(s) around appropriate group(s) in the K-map to produce an optimal
sum-of-products. [2]

(iii) Write the Boolean expression from your answer to part c(ii) as a simplified
sum-of-products.

...........................................................................................................................................

..................................................................................................................................... [1]

7 (a) Outline what is meant by direct access as a method of file access.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Explain how direct access is used to locate a specific record in sequential files and random
files.

(i) Sequential files ..................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) Random files .....................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

© UCLES 2024 9618/32/M/J/24


9

8 (a) Complete the pseudocode to find an item in a 1D array Widgets of type STRING, using a
linear search.

DECLARE Widgets : ARRAY[1:50000] OF STRING


DECLARE TopOfList : INTEGER
DECLARE EndOfList : INTEGER
DECLARE Count : INTEGER
DECLARE ToFind : STRING
DECLARE Found : BOOLEAN
DECLARE NotInList : BOOLEAN
TopOfList 1
EndOfList 50000
OUTPUT "Enter the name of the item you wish to find "
INPUT ToFind

…………………………………………………………………………………………………………………………………
NotInList FALSE
Count TopOfList

WHILE …………………………………………………………… AND ………………………………………………………………………

IF ……………………………………………………………………………………………………………………………… THEN
Found TRUE
ENDIF
Count Count + 1

IF …………………………………………………………………………………………………………………………… THEN
NotInList TRUE
ENDIF
ENDWHILE
IF Found = TRUE THEN
OUTPUT "Item found at position ", Count - 1, " in array"
ELSE
OUTPUT "Item not in array"
ENDIF
[4]

(b) Compare the methods used by the linear and binary search algorithms to find an item in an
array. Refer to Big O notation in your answer.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2024 9618/32/M/J/24 [Turn over


10

9 (a) Outline two benefits and two limitations of a virtual machine.

Benefit 1 ...................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Benefit 2 ...................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Limitation 1 ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Limitation 2 ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

(b) Explain the roles of the host operating system and the guest operating system as used in a
computer system running a virtual machine.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2024 9618/32/M/J/24


11

10 A declarative programming language is used to allow clients to choose daily activities at the
beach.

01 activity(paddleboarding).
02 activity(sailing).
03 activity(rowing).
04 activity(kayaking).
05 activity(jetskiing).
06 client(stevie).
07 client(antonio).
08 client(henry).
09 client(eliza).
10 client(rebeka).
11 client(danny).
12 client(erik).
13 client(simone).
14 client(petra).
15 client(frankie).
16 choice(petra, rowing).
17 choice(frankie, sailing).
18 choice(erik, sailing).
19 choice(eliza, rowing).
20 choice(stevie, jetskiing).
21 choice(henry, sailing).
22 done(henry, jetskiing).
23 done(rebeka, jetskiing).
24 done(antonio, kayaking).

These clauses have the meanings:

Clause Meaning
01 Paddle boarding is an activity.
06 Stevie is a client.
16 Petra has chosen rowing.
22 Henry has already done jet skiing.

(a) Jane is a client who would like to choose the activity surfing and she has already done sailing.

Write additional clauses to represent this information.

25 .............................................................................................................................................

26 .............................................................................................................................................

27 .............................................................................................................................................

28 .............................................................................................................................................
[4]

© UCLES 2024 9618/32/M/J/24 [Turn over


12

(b) Using the variable List, the goal:

choice(List, rowing)

returns

List = petra, eliza

Write the result returned by the goal:

choice(List, sailing)

List = .............................................................................................................................. [1]

(c) C is a client who would like to choose A if A is an activity and C has not already done A.

Write this as a rule:

may_choose_activity(C, A)

IF ............................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

11 Explain what is meant by Reinforcement Learning in relation to Artificial Intelligence.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [3]

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 2024 9618/32/M/J/24


* 0019655539701 *

,  ,

Cambridge International AS & A Level

¬Wz> 3mKsgy=–<—5 W
¬šš`E¤ifbpŠœŠWBtN‚
¥5u•5•Eu5e¥U5 eUEU
* 0 5 3 4 4 0 8 3 9 9 *

COMPUTER SCIENCE 9618/33


Paper 3 Advanced Theory May/June 2024

1 hour 30 minutes

You must answer on the question paper.

No additional materials are needed.

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.

This document has 12 pages. Any blank pages are indicated.

DC (LK/CGW) 329375/5
© UCLES 2024 [Turn over
* 0019655539702 *

DO NOT WRITE IN THIS MARGIN


2
,  ,

1 Real numbers are stored in a computer system using floating-point representation with:

• 10 bits for the mantissa


• 6 bits for the exponent
• two’s complement form for both the mantissa and the exponent.

(a) Calculate the denary value of the given normalised floating-point number.

Show your working.

Mantissa Exponent

DO NOT WRITE IN THIS MARGIN


0 1 0 0 1 1 1 1 0 0 0 0 1 0 0 1

Working .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

DO NOT WRITE IN THIS MARGIN


...................................................................................................................................................

Answer ......................................................................................................................................
[3]

(b) Calculate the normalised floating-point representation of –102.75 in this system.

Show your working.

Mantissa Exponent

Working ..................................................................................................................................... DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................
[3]

ĬÕú¾Ġ³íËóçù½Ė¹ĕ·Ğ×
© UCLES 2024 ĬĚĜßÈĨÝÄÙāð÷²ÝòÌÖĂ
ĥĥĥĕõõąĕąĥµĕµÅÅĕĥÕ
9618/33/M/J/24
* 0019655539703 *
DO NOT WRITE IN THIS MARGIN

3
,  ,

2 The TCP / IP protocol suite has four layers:

Transport, Application, Link, Internet

(a) Complete the diagram to show the correct order for these layers.
DO NOT WRITE IN THIS MARGIN

[2]

(b) Describe the function of the Transport layer.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

............................................................................................................................................. [2]

(c) Outline one protocol that is associated with the Application layer.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]
DO NOT WRITE IN THIS MARGIN

3 (a) Explain what is meant by non-composite and composite data types.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

............................................................................................................................................. [3]

Ĭ×ú¾Ġ³íËóçù½Ė¹ė·Ğ×
© UCLES 2024 ĬĚěàÀĢá´à÷ā²ĦÕæÌæĂ
ĥĥĕÕµĕĥõĕĕĥĕµååÕõÕ
9618/33/M/J/24 [Turn over
* 0019655539704 *

DO NOT WRITE IN THIS MARGIN


4
,  ,

(b) Write pseudocode statements to declare the record data type FootballClub to hold data
about football clubs in a league, to include:

• name of team
• date team joined the league
• main telephone number
• name of the manager
• number of members
• current position in the league.

...................................................................................................................................................

DO NOT WRITE IN THIS MARGIN


...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

DO NOT WRITE IN THIS MARGIN


...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

4 (a) Describe the sequential method of file access.

...................................................................................................................................................

...................................................................................................................................................

DO NOT WRITE IN THIS MARGIN


...................................................................................................................................................

............................................................................................................................................. [2]

(b) Explain how the sequential method of file access is applied to files with serial organisation
and to files with sequential organisation.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

ĬÕú¾Ġ³íËóçù½Ė»ĕ·Ġ×
© UCLES 2024 ĬĚěÝÀĬÓµÛùĊ¹ÈùĈÜÎĂ
ĥÕÅÕõĕĥÕõµĕĕõåąÕĥÕ
9618/33/M/J/24
* 0019655539705 *
DO NOT WRITE IN THIS MARGIN

5
,  ,

5 (a) Write this Reverse Polish Notation (RPN) in infix form:

5 2 + 9 3 - / 3 *

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]
DO NOT WRITE IN THIS MARGIN

(b) Write this infix expression in RPN:

((7 + 3) - (2 * 8)) / 6

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]
DO NOT WRITE IN THIS MARGIN

(c) Evaluate this RPN expression:

a b - c d + * e /

when

a = 17, b = 5, c = 7, d = 3 and e = 10

Show the changing contents of the stack as the RPN expression is evaluated.
DO NOT WRITE IN THIS MARGIN

[4]
DO NOT WRITE IN THIS MARGIN

Ĭ×ú¾Ġ³íËóçù½Ė»ė·Ġ×
© UCLES 2024 ĬĚĜÞÈĞÏÅÞÿ÷ðĔāÔÜÞĂ
ĥÕµĕµõąµĥÅÅĕõÅĥĕõÕ
9618/33/M/J/24 [Turn over
* 0019655539706 *

DO NOT WRITE IN THIS MARGIN


6
,  ,

6 The diagram shows a logic circuit.

A Q

P R
B Z

DO NOT WRITE IN THIS MARGIN


S

(a) Complete the truth table for the given logic circuit.

Show your working.

DO NOT WRITE IN THIS MARGIN


Working space
A B C P Q R S Z

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

DO NOT WRITE IN THIS MARGIN


1 1 0

1 1 1
[3]

(b) Write the Boolean expression that corresponds to the logic circuit as a sum-of-products.

Z = ............................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

............................................................................................................................................. [2]

ĬÙú¾Ġ³íËóçù½Ėºė¶Ğ×
© UCLES 2024 ĬĚěÞËĨ·¿æČĆąôù±ôÎĂ
ĥąĕĕµÕąĕååĥĕµÅÅÕåÕ
9618/33/M/J/24
* 0019655539807 *
DO NOT WRITE IN THIS MARGIN

7
,  ,

(c) (i) Complete the Karnaugh map (K-map) for the Boolean expression:

A.B.C + A.B.C + A.B.C + A.B.C + A.B.C + A.B.C

BC
00 01 11 10
A

1
DO NOT WRITE IN THIS MARGIN

[2]

(ii) Draw loop(s) around appropriate group(s) in the K-map to produce an optimal
sum-of-products. [2]

(iii) Write the Boolean expression from your answer to part (c)(ii) as a simplified
sum-of-products.

...........................................................................................................................................

..................................................................................................................................... [1]
DO NOT WRITE IN THIS MARGIN

7 (a) Describe what is meant by a digital certificate.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

............................................................................................................................................. [3]

(b) Explain the role of a digital certificate in creating a digital signature.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]
DO NOT WRITE IN THIS MARGIN

ĬÛù¿Ġ³íËóçù½Ė¹ė¶Ğ×
© UCLES 2024 ĬĚěàÈīÈéÕĉú²Ë¹±ÄæĂ
ĥµµÕµõåõÅåÅĕõąÅĕĕÕ
9618/33/M/J/24 [Turn over
* 0019655539808 *

DO NOT WRITE IN THIS MARGIN


8
,   ,

8 A declarative programming language is used to represent the features that are available and the
features that are unavailable on different body styles of a car.

01 feature(sunroof).
02 feature(automatic_tailgate).
03 feature(heated_seats).
04 feature(extra_seats).
05 feature(reversing_camera).
06 feature(dashboard_camera).
07 feature(air_conditioning).
08 feature(heated_windscreen).

DO NOT WRITE IN THIS MARGIN


09 feature(satnav).
10 bodystyle(saloon).
11 bodystyle(hatchback).
12 bodystyle(estate).
13 bodystyle(minivan).
14 bodystyle(convertible).
15 available(sunroof, hatchback).
16 available(sunroof, minivan).
17 available(reversing_camera, hatchback).
18 available(extra_seats, minivan).
19 available(reversing_camera, saloon).
20 unavailable(sunroof, convertible).

DO NOT WRITE IN THIS MARGIN


21 unavailable(automatic_tailgate, saloon).
22 unavailable(extra_seats, hatchback).

These clauses have the meanings:

Clause Meaning
01 Sunroof is a feature.
10 Saloon is a body style.
15 Sunroof is available on a hatchback.
20 Sunroof is unavailable on a convertible.

DO NOT WRITE IN THIS MARGIN


(a) Sliding doors is a feature that is available on a minivan but unavailable on a hatchback.

Write additional clauses to represent this information.

23 .............................................................................................................................................

24 .............................................................................................................................................

25 .............................................................................................................................................
[3]
DO NOT WRITE IN THIS MARGIN

ĬÙù¿Ġ³íËóçù½Ė»ĕ¶Ġ×
© UCLES 2024 ĬĚěÝÈġ¶àâćñ¹ĩĕēÔÎĂ
ĥąĥÕõõåÕåąµĕµąĥĕąÕ
9618/33/M/J/24
* 0019655539809 *
DO NOT WRITE IN THIS MARGIN

9
,   ,

(b) Using the variable Options, the goal:

available(Options, saloon)

returns

Options = reversing_camera

Write the result returned by the goal:

available(Options, hatchback)
DO NOT WRITE IN THIS MARGIN

Options = ........................................................................................................................ [1]

(c) F may be available for B if F is a feature and B is a body style and F is not unavailable for that
body style.

Write this as a rule:

may_choose_option(F, B)

IF .............................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

9 Explain what is meant by Deep Learning in relation to Artificial Intelligence (AI).

..........................................................................................................................................................

..........................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [3]
DO NOT WRITE IN THIS MARGIN

ĬÛù¿Ġ³íËóçù½Ė»ė¶Ġ×
© UCLES 2024 ĬĚĜÞÀħºÐ×ñĀð­ĝÇÔÞĂ
ĥąĕĕµĕŵµõĥĕµĥąÕĕÕ
9618/33/M/J/24 [Turn over
* 0019655539810 *

DO NOT WRITE IN THIS MARGIN


10
,  ,

10 (a) State a condition that must be true for an array to be searchable for a binary search.

...................................................................................................................................................

............................................................................................................................................. [1]

(b) Complete the given pseudocode to find an item in a 1D array Names of type STRING using a
binary search.

DECLARE Names : ARRAY[1:100000] OF STRING


DECLARE TopOfList : INTEGER

DO NOT WRITE IN THIS MARGIN


DECLARE EndOfList : INTEGER
DECLARE CurrentItem : INTEGER
DECLARE ToFind : STRING
DECLARE Found : BOOLEAN
DECLARE NotInList : BOOLEAN
TopOfList 1 ←
EndOfList 100000 ←
OUTPUT "Which name do you wish to find? "
INPUT ToFind

...................................................................................................................................................

DO NOT WRITE IN THIS MARGIN


NotInList ← FALSE
WHILE ................................................ AND ................................................
CurrentItem ←
(TopOfList + EndOfList) DIV 2

IF ........................................................................................................... THEN
Found ← TRUE
ELSE
IF TopOfList >= EndOfList THEN

...........................................................................................................
ELSE

DO NOT WRITE IN THIS MARGIN


IF ToFind > Names[CurrentItem] THEN

...........................................................................................................
ELSE
EndOfList ←
CurrentItem – 1
ENDIF
ENDIF
ENDIF
ENDWHILE
IF Found = TRUE THEN
OUTPUT "Item found at position ", CurrentItem, " in array"
ELSE
OUTPUT "Item not in array"
DO NOT WRITE IN THIS MARGIN

ENDIF
[5]

ĬÙù¿Ġ³íËóçù½Ėºĕ¸Ğ×
© UCLES 2024 ĬĚĚÝ½ģ®ºàĀúēąė÷ĬæĂ
ĥÕąĕõõąÕąµµÕµåĥĕµÕ
9618/33/M/J/24
* 0019655539811 *
DO NOT WRITE IN THIS MARGIN

11
,  ,

(c) Describe the performance of a binary search in relation to the number of data items in the
array being searched. Refer to Big O notation in your answer.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]
DO NOT WRITE IN THIS MARGIN

11 Reduced Instruction Set Computers (RISC) and Complex Instruction Set Computers (CISC) are
two types of processor.

(a) State two features of RISC processors.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

............................................................................................................................................. [2]

(b) Outline the process of interrupt handling as it could be applied to RISC or CISC processors.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

............................................................................................................................................. [3]

(c) Explain how pipelining affects interrupt handling for RISC processors.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN

...................................................................................................................................................

............................................................................................................................................. [3]

ĬÛù¿Ġ³íËóçù½Ėºė¸Ğ×
© UCLES 2024 ĬĚęÞÅĥ²ÊÙúćÖÑğãĬÖĂ
ĥÕõÕµĕĥµĕÅĥÕµÅąÕåÕ
9618/33/M/J/24
* 0019655539812 *

DO NOT WRITE IN THIS MARGIN


12
,  ,

BLANK PAGE

DO NOT WRITE IN THIS MARGIN


DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN

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 2024 ĬĚęßÅğÄ¿ÞøĀÍóÃāüÞĂ
ĥĥåÕõĕĥĕõĥĕÕõÅåÕµÕ
9618/33/M/J/24
Cambridge International AS & A Level

COMPUTER SCIENCE 9618/41


Paper 4 Practical May/June 2024

2 hours 30 minutes

You will need: Candidate source files (listed on page 2)


* 9 4 0 9 4 1 6 3 6 7 *

evidence.doc

INSTRUCTIONS
● Carry out every instruction in each task.
● Save your work using the file names given in the task as and when instructed.
● You must not have access to either the internet or any email system during this examination.
● You must save your work in the evidence document as stated in the tasks. If work is not saved in the
evidence document, you will not receive marks for that task.
● You must use a high‑level programming language from this list:
Java (console mode)
Python (console mode)
Visual Basic (console mode)
● A mark of zero will be awarded if a programming language other than those listed here is used.

INFORMATION
● The total mark for this paper is 75.
● The number of marks for each question or part question is shown in brackets [ ].

This document has 16 pages. Any blank pages are indicated.

DC (WW) 340659
© UCLES 2024 [Turn over
2

Open the evidence document evidence.doc

Make sure that your name, centre number and candidate number will appear on every page of this
document. This document must contain your answers to each question.

Save this evidence document in your work area as:

evidence_ followed by your centre number_candidate number, for example: evidence_zz999_9999

A class declaration can be used to declare a record.

If the programming language used does not support arrays, a list can be used instead.

One source file is used to answer Question 2. The file is called Trees.txt

1 A program needs to take integer numbers as input, sort the numbers and then search for a specific
number.

(a) The integer numbers will be stored in the global 1D array, DataStored, with space for up to
20 integers.

The global variable NumberItems stores the quantity of items the array contains.

Write program code to declare DataStored and NumberItems.

Save your program as Question1_J24.

Copy and paste the program code into part 1(a) in the evidence document.
[1]

(b) The procedure Initialise():

• prompts the user to input the quantity of numbers the user would like to enter
• reads the input and validates it is between 1 and 20 (inclusive)
• prompts the user to input each number and stores each number in DataStored.

Write program code for Initialise().

Save your program.

Copy and paste the program code into part 1(b) in the evidence document.
[5]

© UCLES 2024 9618/41/M/J/24


3

(c) The main program stores 0 in NumberItems, calls Initialise() and then outputs the
contents of DataStored.

(i) Write program code for the main program.

Save your program.

Copy and paste the program code into part 1(c)(i) in the evidence document.
[2]

(ii) Test your program by inputting the following data in the order given:

30
5
3
9
4
1
2
Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 1(c)(ii) in the evidence document.
[2]

(d) The procedure BubbleSort() uses a bubble sort to sort the data in DataStored into
ascending numerical order.

(i) Write program code for BubbleSort().

Save your program.

Copy and paste the program code into part 1(d)(i) in the evidence document.
[4]

(ii) Write program code to amend the main program to call BubbleSort() and then output
the contents of DataStored.

Save your program.

Copy and paste the program code into part 1(d)(ii) in the evidence document.
[1]

© UCLES 2024 9618/41/M/J/24 [Turn over


4

(iii) Test your program by inputting the following data in the order given:

5
3
9
4
1
2
Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 1(d)(iii) in the evidence document.
[1]

(e) The function BinarySearch():

• takes the integer parameter DataToFind to search for in the array


• performs an iterative binary search on the array DataStored
• returns the index where DataToFind is found in DataStored. If DataToFind is not
found, the function returns −1.

(i) Write program code for the iterative function BinarySearch().

Save your program.

Copy and paste the program code into part 1(e)(i) in the evidence document.
[6]

(ii) Write program code to amend the main program to:

• take a number as input from the user


• call BinarySearch() with the number input
• output the value returned from the function call as its parameter.

Save your program.

Copy and paste the program code into part 1(e)(ii) in the evidence document.
[3]

© UCLES 2024 9618/41/M/J/24


5

(iii) Test your program twice with the following inputs:

Test 1: 5 1 6 2 8 10 2

Test 2: 5 1 6 2 8 10 7

Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 1(e)(iii) in the evidence document.
[2]

© UCLES 2024 9618/41/M/J/24 [Turn over


6

2 A computer program will store data about trees.

The user can enter their requirements for a tree and a suitable tree will be selected.

The program is written using object‑oriented programming.

The class Tree stores data about the trees.

Tree
TreeName : STRING stores the name of the tree

HeightGrowth : INTEGER stores the number of cm the tree will grow each year

MaxHeight : INTEGER stores the maximum height in cm that the tree will grow

MaxWidth : INTEGER stores the maximum width in cm that the tree will grow

Evergreen : STRING stores whether the tree keeps its leaves as "Yes", or
loses its leaves as "No"
Constructor() initialises TreeName, HeightGrowth, MaxHeight,
MaxWidth and Evergreen to its parameter values

GetTreeName() returns the name of the tree

GetGrowth() returns the number of cm the tree will grow each year

GetMaxHeight() returns the maximum height in cm that the tree will grow

GetMaxWidth() returns the maximum width in cm that the tree will grow

GetEvergreen() returns whether the tree keeps its leaves or loses its
leaves

(a) (i) Write program code to declare the class Tree and its constructor.

Do not declare the other methods.

Use the appropriate constructor for your programming language.

All attributes must be private.

If you are writing in Python, include attribute declarations using comments.

Save your program as Question2_J24.

Copy and paste the program code into part 2(a)(i) in the evidence document.
[4]

© UCLES 2024 9618/41/M/J/24


7

(ii) The get methods GetTreeName(), GetGrowth(), GetMaxHeight(),


GetMaxWidth() and GetEvergreen() each return the relevant attribute.

Write program code for the get methods.

Save your program.

Copy and paste the program code into part 2(a)(ii) in the evidence document.
[3]

(b) The text file Trees.txt stores data about 9 trees.

The data in the file is stored in the format:

Tree name,Height growth each year,Maximum height,Maximum width,Evergreen

For example, the first row of data is:

Beech,30,400,200,No

The tree is a Beech. It can grow 30 cm each year. It has a maximum height of 400 cm.
It has a maximum width of 200 cm. It is not evergreen (it loses its leaves).

The function ReadData():

• creates an array of type Tree


• reads the data from the file
• raises an exception if the file is not found
• creates a new object of type Tree for each tree in the file
• appends each object to the array
• returns the array.

Write program code for ReadData().

Save your program.

Copy and paste the program code into part 2(b) in the evidence document.
[7]

© UCLES 2024 9618/41/M/J/24 [Turn over


8

(c) The procedure PrintTrees() takes a Tree object as a parameter and outputs the tree’s
name, height growth each year, maximum height, maximum width and whether it is evergreen.

The output message changes depending on whether it is evergreen.

If it is evergreen, it is in the format:

TreeName has a maximum height MaxHeight a maximum width MaxWidth and grows
HeightGrowth cm a year. It does not lose its leaves.

If it is not evergreen, it is in the format:

TreeName has a maximum height MaxHeight a maximum width MaxWidth and grows
HeightGrowth cm a year. It loses its leaves each year.

Write program code for PrintTrees().

Save your program.

Copy and paste the program code into part 2(c) in the evidence document.
[4]

(d) The main program calls ReadData(), stores the return value and calls PrintTrees() with
the first object in the returned array.

(i) Write program code for the main program.

Save your program.

Copy and paste the program code into part 2(d)(i) in the evidence document.
[2]

(ii) Test your program.

Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 2(d)(ii) in the evidence document.
[1]

© UCLES 2024 9618/41/M/J/24


9

(e) The procedure ChooseTree() takes an array of Tree objects as a parameter.

The procedure prompts the user to input their requirements for a tree.
The user needs to enter:

• the maximum height the tree can be in cm


• the maximum width the tree can be in cm
• whether they want the tree to be evergreen, or not evergreen.

A tree meets the requirements if:

• the tree’s maximum height is not more than the user’s input

and

• the tree’s maximum width is not more than the user’s input

and

• the tree matches their evergreen input.

The procedure creates a new array of all the Tree objects that meet all the requirements.

The procedure calls PrintTrees() for each Tree object that meets all the requirements. If
there are no trees that meet all the requirements, a suitable message is output.

(i) Write program code for ChooseTree().

Save your program.

Copy and paste the program code into part 2(e)(i) in the evidence document.
[6]

(ii) The procedure ChooseTree() needs amending. After the procedure has output the list
of trees that meet all the requirements, the procedure needs to:

• take as input the name of one of the trees that the user would like to buy from those
that meet all the requirements
• take as input the height of the tree in cm when it is bought
• calculate and output how many years it will take the tree to grow to its maximum
height.

For example, the user inputs the tree, Beech. The tree’s height is 40 cm when bought.
The tree will take 12 years to reach its maximum height of 400 cm.

Write program code to amend ChooseTree().

Save your program.

Copy and paste the program code into part 2(e)(ii) in the evidence document.
[2]

© UCLES 2024 9618/41/M/J/24 [Turn over


10

(iii) Write program code to amend the main program to call ChooseTrees().

Test your program with the following tree requirements:

• a maximum height of 400 cm


• a maximum width of 200 cm
• a tree that is evergreen (does not lose its leaves).

When asked for the tree selection, use the following data:

• first tree name entered is ‘Blue Conifer’


• starting height is 100 cm.

Take a screenshot of the outputs.

Save your program.

Copy and paste the screenshot into part 2(e)(iii) in the evidence document.
[2]

© UCLES 2024 9618/41/M/J/24


11

3 A program reads data from the user and stores the data that is valid in a linear queue.

The queue is stored as a global 1D array, QueueData, of string values. The array needs space for
20 elements.

The global variable QueueHead stores the index of the first element in the queue.
The global variable QueueTail stores the index of the last element in the queue.

(a) The main program initialises all the elements in QueueData to a suitable null value,
QueueHead to −1 and QueueTail to −1.

Write program code for the main program.

Save your program as Question3_J24.

Copy and paste the program code into part 3(a) in the evidence document.
[1]

(b) The function Enqueue() takes the data to insert into the queue as a parameter.

If the queue is not full, it inserts the parameter in the queue, updates the appropriate pointer(s)
and returns TRUE. If the queue is full, it returns FALSE.

Write program code for Enqueue().

Save your program.

Copy and paste the program code into part 3(b) in the evidence document.
[4]

(c) The function Dequeue() returns "false" if the queue is empty. If the queue is not empty, it
returns the next item in the queue and updates the appropriate pointer(s).

Write program code for Dequeue().

Save your program.

Copy and paste the program code into part 3(c) in the evidence document.
[3]

© UCLES 2024 9618/41/M/J/24 [Turn over


12

(d) The string values to be stored in the queue are 7 characters long. The first 6 characters are
digits and the 7th character is a check digit. The check digit is calculated from the first 6 digits
using this algorithm:

• multiply the digits in position 0, position 2 and position 4 by 1


• multiply the digits in position 1, position 3 and position 5 by 3
• calculate the sum of the products (add together the results from all of the multiplications)
• divide the sum of the products by 10 and round the result down to the nearest integer to
get the check digit
• if the check digit equals 10 then it is replaced with 'X'.

Example:

Data is 954123

Character position 0 1 2 3 4 5
Digit 9 5 4 1 2 3
Multiplier 1 3 1 3 1 3
Product 9 15 4 3 2 9

Sum of products = 9 + 15 + 4 + 3 + 2 + 9 = 42

Divide sum of products by 10: 42 / 10 = 4 (rounded down)

The check digit = 4. This is inserted into character position 6.

The data including the check digit is: 9541234

A 7‑character string is valid if the 7th character matches the check digit for that data. For
example, the data 9541235 is invalid because the 7th character (5) does not match the check
digit for 954123.

(i) The subroutine StoreItems() takes ten 7‑character strings as input from the user and
uses the check digit to validate each input.

Each valid input has the check digit removed and is stored in the queue using
Enqueue().
An appropriate message is output if the item is inserted. An appropriate message is
output if the queue is already full.

Invalid inputs are not stored in the queue.

The subroutine counts and outputs the number of invalid items that were entered.

StoreItems() can be a procedure or a function as appropriate.

Write program code for StoreItems().

Save your program.

Copy and paste the program code into part 3(d)(i) in the evidence document.
[6]

© UCLES 2024 9618/41/M/J/24


13

(ii) Write program code to amend the main program to:

• call StoreItems()
• call Dequeue()
• output a suitable message if the queue was empty
• output the returned value if the queue was not empty.

Save your program.

Copy and paste the program code into part 3(d)(ii) in the evidence document.
[1]

(iii) Test the program with the following inputs in the order given:

999999X
1251484
5500212
0033585
9845788
6666666
3258746
8111022
7568557
0012353

Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 3(d)(iii) in the evidence document.
[2]

© UCLES 2024 9618/41/M/J/24


14

BLANK PAGE

© UCLES 2024 9618/41/M/J/24


15

BLANK PAGE

© UCLES 2024 9618/41/M/J/24


16

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 2024 9618/41/M/J/24


Cambridge International AS & A Level

COMPUTER SCIENCE 9618/42


Paper 4 Practical May/June 2024

2 hours 30 minutes

You will need: Candidate source files (listed on page 2)


* 3 7 5 6 1 7 6 8 0 0 *

evidence.doc

INSTRUCTIONS
● Carry out every instruction in each task.
● Save your work using the file names given in the task as and when instructed.
● You must not have access to either the internet or any email system during this examination.
● You must save your work in the evidence document as stated in the tasks. If work is not saved in the
evidence document, you will not receive marks for that task.
● You must use a high‑level programming language from this list:
Java (console mode)
Python (console mode)
Visual Basic (console mode)
● A mark of zero will be awarded if a programming language other than those listed here is used.

INFORMATION
● The total mark for this paper is 75.
● The number of marks for each question or part question is shown in brackets [ ].

This document has 16 pages. Any blank pages are indicated.

DC (PQ/CGW) 329377/3
© UCLES 2024 [Turn over
2

Open the evidence document evidence.doc

Make sure that your name, centre number and candidate number will appear on every page of this
document. This document must contain your answers to each question.

Save this evidence document in your work area as:


evidence_ followed by your centre number_candidate number, for example: evidence_zz999_9999

A class declaration can be used to declare a record. If the programming language used does not
support arrays, a list can be used instead.

Three source files are used to answer Question 1. The files are called Easy.txt, Medium.txt and
Hard.txt

1 A program outputs a main word. The program asks the user to enter the different words of 3 or
more letters that can be made from the letters in the main word. These are called the answers.

There are 3 files: Easy.txt, Medium.txt and Hard.txt. Each file has the main word on the
first line. For example, the main word in Easy.txt is house.

The answers are stored in the file. Each answer is on a new line after the main word. For example,
Easy.txt has 14 answers that can be made from the letters in house.

The words read from the text file are stored in the global array WordArray. The number of words
that can be made from the letters in the main word is stored in the global variable NumberWords.

(a) The procedure ReadWords():

• takes a file name as a parameter


• opens the file and reads in the data
• stores the main word in the first element in WordArray
• stores each answer in a new element in WordArray
• counts and stores the number of answers.

Write program code for the procedure ReadWords().

Save your program as Question1_J24.

Copy and paste the program code into part 1(a) in the evidence document.
[6]

(b) The main program asks the user to enter "easy", "medium" or "hard" and calls
ReadWords()with the filename that matches the user’s input. For example, if the user enters
"easy", the parameter is "Easy.txt".

Write program code for the main program.

Save your program.

Copy and paste the program code into part 1(b) in the evidence document.
[4]

© UCLES 2024 9618/42/M/J/24


3

(c) (i) The procedure Play():

• outputs the main word from the array and the number of answers
• allows the user to enter words until they enter the word ‘no’ to indicate they want to
stop
• outputs whether each word the user enters is an answer or not an answer
• counts the number of answers the user gets correct
• replaces each answer that the user gets correct with a null value in the array.

Write program code for the procedure Play().

Save your program.

Copy and paste the program code into part 1(c)(i) in the evidence document.
[6]

(ii) Amend the procedure Play()so that when the user enters the command to stop, the
procedure:

• outputs the percentage of answers the user entered from the array
• outputs all the answers that the user did not enter.

Write program code to amend Play().

Save your program.

Copy and paste the program code into part 1(c)(ii) in the evidence document.
[3]

(d) (i) The procedure ReadWords()calls Play()after the data in the file has been read.

Write program code to amend ReadWords().

Save your program.

Copy and paste the program code into part 1(d)(i) in the evidence document.
[1]

© UCLES 2024 9618/42/M/J/24 [Turn over


4

(ii) Test your program by inputting these words in the order shown:

easy

she

out

no

Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 1(d)(ii) in the evidence document.
[1]
(iii) Test your program by inputting these words in the order shown:

hard

fine

fined

idea

no

Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 1(d)(iii) in the evidence document.
[1]

© UCLES 2024 9618/42/M/J/24


5

BLANK PAGE

© UCLES 2024 9618/42/M/J/24 [Turn over


6

2 A binary tree stores data in ascending order. For example:

15

8 19

3 10
A computer program stores integers in a binary tree in ascending order. The program uses
Object‑Oriented Programming (OOP).

The binary tree is stored as a 1D array of nodes. Each node contains a left pointer, a data value
and a right pointer.

The class Node stores the data about a node.

Node
LeftPointer : INTEGER stores the index of the node to the left in the binary tree

Data : INTEGER stores the node’s data

RightPointer : INTEGER stores the index of the node to the right in the binary tree
Constructor() initialises Data to its parameter value
initialises LeftPointer and RightPointer to −1

GetLeft() returns the left pointer

GetRight() returns the right pointer

GetData() returns the data value

SetLeft() assigns the parameter to the left pointer

SetRight() assigns the parameter to the right pointer

SetData() assigns the parameter to the data

(a) (i) Write program code to declare the class Node and its constructor.

Do not declare the other methods.

Use the appropriate constructor for your programming language.

If you are writing in Python, include attribute declarations using comments.

Save your program as Question2_J24.

Copy and paste the program code into part 2(a)(i) in the evidence document.
[4]
© UCLES 2024 9618/42/M/J/24
7

(ii) The get methods GetLeft(), GetRight()and GetData()each return the relevant
attribute.

Write program code for the three get methods.

Save your program.

Copy and paste the program code into part 2(a)(ii) in the evidence document.
[3]

(iii) The set methods SetLeft(), SetRight()and SetData()each take a parameter and
then store this in the relevant attribute.

Write program code for the three set methods.

Save your program.

Copy and paste the program code into part 2(a)(iii) in the evidence document.
[3]

(b) The class TreeClass stores the data about the binary tree.

TreeClass
Tree[0:19] : Node an array of 20 elements of type Node

FirstNode : INTEGER stores the index of the first node in the tree

NumberNodes : INTEGER stores the quantity of nodes in the tree


Constructor() initialises FirstNode to −1 and NumberNodes to 0
initialises each element in Tree to a Node object with the
data value of −1

InsertNode() takes a Node object as a parameter, inserts it in the array


and updates the pointer for its parent node

OutputTree() outputs the left pointer, data and right pointer of each
node in Tree

Nodes cannot be deleted from this tree.

(i) Write program code to declare the class TreeClass and its constructor.

Do not declare the other methods.

Use the appropriate constructor for your programming language.

If you are writing in Python, include attribute declarations using comments.

Save your program.

Copy and paste the program code into part 2(b)(i) in the evidence document.
[4]
© UCLES 2024 9618/42/M/J/24 [Turn over
8

(ii) The method InsertNode()takes a Node object, NewNode, as a parameter and inserts
it into the array Tree.

InsertNode()first checks if the tree is empty.

If the tree is empty, InsertNode():

• stores NewNode in the array Tree at index NumberNodes


• increments NumberNodes
• stores 0 in FirstNode.

If the tree is not empty, InsertNode():

• stores NewNode in the array Tree at index NumberNodes


• accesses the data in the array Tree at index FirstNode and compares it to the
data in NewNode
• repeatedly follows the pointers until the correct position for NewNode is found
• once the position is found, InsertNode()sets the left or right pointer of its parent
node
• increments NumberNodes.

Write program code for InsertNode().

Save your program.

Copy and paste the program code into part 2(b)(ii) in the evidence document.
[6]

(iii) The method OutputTree()outputs the left pointer, the data and the right pointer for
each node that has been inserted into the tree. The outputs are in the order they are
saved in the array.

If there are no nodes in the array, the procedure outputs ‘No nodes’.

Write program code for OutputTree().

Save your program.

Copy and paste the program code into part 2(b)(iii) in the evidence document.
[4]

© UCLES 2024 9618/42/M/J/24


9

(c) (i) The main program declares an instance of TreeClass with the identifier TheTree.

Write program code for the main program.

Save your program.

Copy and paste the program code into part 2(c)(i) in the evidence document.
[1]

(ii) The main program inserts the following integers into the binary tree in the order given:

10

11

20

15

The main program then calls the method OutputTree().

Write program code to amend the main program.

Save your program.

Copy and paste the program code into part 2(c)(ii) in the evidence document.
[4]

(iii) Test your program.

Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 2(c)(iii) in the evidence document.
[1]

© UCLES 2024 9618/42/M/J/24 [Turn over


10

3 A program sorts an array of integers and searches the array for a particular value.

(a) The array of integers, NumberArray, stores the following data in the order given:

100 85 644 22 15 8 1

The array is declared and initialised local to the main program.

Write program code to declare and initialise the array.

Save your program as Question3_J24.

Copy and paste the program code into part 3(a) in the evidence document.
[1]

© UCLES 2024 9618/42/M/J/24


11

(b) (i) The following recursive pseudocode function sorts the array into ascending order using
an insertion sort and returns the sorted array.

DECLARE LastItem : INTEGER


DECLARE CheckItem : INTEGER
DECLARE LoopAgain : BOOLEAN
FUNCTION RecursiveInsertion(IntegerArray : ARRAY[] OF INTEGER,
NumberElements : INTEGER) RETURNS ARRAY[] OF INTEGER
IF NumberElements <= 1 THEN
RETURN IntegerArray
ELSE
CALL RecursiveInsertion(IntegerArray, NumberElements - 1)
LastItem IntegerArray[NumberElements - 1]
CheckItem NumberElements - 2
ENDIF
LoopAgain TRUE
IF CheckItem < 0 THEN
LoopAgain FALSE
ELSE
IF IntegerArray[CheckItem] < LastItem THEN
LoopAgain FALSE
ENDIF
ENDIF
WHILE LoopAgain
IntegerArray[CheckItem + 1] IntegerArray[CheckItem]
CheckItem CheckItem - 1
IF CheckItem < 0 THEN
LoopAgain FALSE
ELSE
IF IntegerArray[CheckItem] < LastItem THEN
LoopAgain FALSE
ENDIF
ENDIF
ENDWHILE
IntegerArray[CheckItem + 1] LastItem
RETURN IntegerArray
ENDFUNCTION

Write the program code for the pseudocode function RecursiveInsertion().

Save your program.

Copy and paste the program code into part 3(b)(i) in the evidence document.
[4]

© UCLES 2024 9618/42/M/J/24 [Turn over


12

(ii) Amend the main program to:

• call RecursiveInsertion()with the initialised array NumberArray and the


number of elements as parameters
• output the word ‘Recursive’
• output the content of the returned array.

Save your program.

Copy and paste the program code into part 3(b)(ii) in the evidence document.
[2]

(iii) Test your program.

Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 3(b)(iii) in the evidence document.
[1]

(c) The function RecursiveInsertion()can be changed to use iteration instead of recursion.

(i) Write program code for the function IterativeInsertion()to perform the same
processes as RecursiveInsertion()but using iteration instead of recursion.

Save your program.

Copy and paste the program code into part 3(c)(i) in the evidence document.
[4]

(ii) Write program code to amend the main program to also:

• call IterativeInsertion()with the original initialised array NumberArray


• output the word ‘iterative’
• output the content of the returned array.

Save your program.

Copy and paste the program code into part 3(c)(ii) in the evidence document.
[1]

(iii) Test your program.

Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 3(c)(iii) in the evidence document.
[1]

© UCLES 2024 9618/42/M/J/24


13

(d) The recursive function BinarySearch()takes the parameters:

• IntegerArray – an array of integers


• First – the index of the first array element
• Last – the index of the last array element
• ToFind – an integer to search for in the array.

The function uses recursion to perform a binary search for ToFind in IntegerArray.
The function returns the index where ToFind is stored or returns −1 if ToFind is not in the
array.

(i) Write program code for the recursive function BinarySearch().

Save your program.

Copy and paste the program code into part 3(d)(i) in the evidence document.
[6]

(ii) Write program code to amend the main program to:

• call BinarySearch()with the sorted array and the integer 644 as the search value
• output ‘Not found’ if 644 is not found in the array
• output the index if 644 is found in the array.

Save your program.

Copy and paste the program code into part 3(d)(ii) in the evidence document.
[2]

(iii) Test your program.

Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 3(d)(iii) in the evidence document.
[1]

© UCLES 2024 9618/42/M/J/24


14

BLANK PAGE

© UCLES 2024 9618/42/M/J/24


15

BLANK PAGE

© UCLES 2024 9618/42/M/J/24


16

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 2024 9618/42/M/J/24


Cambridge International AS & A Level

COMPUTER SCIENCE 9618/43


Paper 4 Practical May/June 2024

2 hours 30 minutes

You will need: Candidate source files (listed on page 2)


* 0 0 9 5 7 4 4 4 0 5 *

evidence.doc

INSTRUCTIONS
● Carry out every instruction in each task.
● Save your work using the file names given in the task as and when instructed.
● You must not have access to either the internet or any email system during this examination.
● You must save your work in the evidence document as stated in the tasks. If work is not saved in the
evidence document, you will not receive marks for that task.
● You must use a high‑level programming language from this list:
Java (console mode)
Python (console mode)
Visual Basic (console mode)
● A mark of zero will be awarded if a programming language other than those listed here is used.

INFORMATION
● The total mark for this paper is 75.
● The number of marks for each question or part question is shown in brackets [ ].

This document has 16 pages. Any blank pages are indicated.

DC (SL) 329378/3
© UCLES 2024 [Turn over
2

Open the evidence document evidence.doc

Make sure that your name, centre number and candidate number will appear on every page of this
document. This document must contain your answers to each question.

Save this evidence document in your work area as:

evidence_ followed by your centre number_candidate number, for example: evidence_zz999_9999

A class declaration can be used to declare a record.

If the programming language used does not support arrays, a list can be used instead.

One source file is used to answer Question 2. The file is called Trees.txt

1 A program needs to take integer numbers as input, sort the numbers and then search for a specific
number.

(a) The integer numbers will be stored in the global 1D array, DataStored, with space for up to
20 integers.

The global variable NumberItems stores the quantity of items the array contains.

Write program code to declare DataStored and NumberItems.

Save your program as Question1_J24.

Copy and paste the program code into part 1(a) in the evidence document.
[1]

(b) The procedure Initialise():

• prompts the user to input the quantity of numbers the user would like to enter
• reads the input and validates it is between 1 and 20 (inclusive)
• prompts the user to input each number and stores each number in DataStored.

Write program code for Initialise().

Save your program.

Copy and paste the program code into part 1(b) in the evidence document.
[5]

© UCLES 2024 9618/43/M/J/24


3

(c) The main program stores 0 in NumberItems, calls Initialise() and then outputs the
contents of DataStored.

(i) Write program code for the main program.

Save your program.

Copy and paste the program code into part 1(c)(i) in the evidence document.
[2]

(ii) Test your program by inputting the following data in the order given:

30
5
3
9
4
1
2
Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 1(c)(ii) in the evidence document.
[2]

(d) The procedure BubbleSort() uses a bubble sort to sort the data in DataStored into
ascending numerical order.

(i) Write program code for BubbleSort().

Save your program.

Copy and paste the program code into part 1(d)(i) in the evidence document.
[4]

(ii) Write program code to amend the main program to call BubbleSort() and then output
the contents of DataStored.

Save your program.

Copy and paste the program code into part 1(d)(ii) in the evidence document.
[1]

© UCLES 2024 9618/43/M/J/24 [Turn over


4

(iii) Test your program by inputting the following data in the order given:

5
3
9
4
1
2
Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 1(d)(iii) in the evidence document.
[1]

(e) The function BinarySearch():

• takes the integer parameter DataToFind to search for in the array


• performs an iterative binary search on the array DataStored
• returns the index where DataToFind is found in DataStored. If DataToFind is not
found, the function returns −1.

(i) Write program code for the iterative function BinarySearch().

Save your program.

Copy and paste the program code into part 1(e)(i) in the evidence document.
[6]

(ii) Write program code to amend the main program to:

• take a number as input from the user


• call BinarySearch() with the number input
• output the value returned from the function call as its parameter.

Save your program.

Copy and paste the program code into part 1(e)(ii) in the evidence document.
[3]

© UCLES 2024 9618/43/M/J/24


5

(iii) Test your program twice with the following inputs:

Test 1: 5 1 6 2 8 10 2

Test 2: 5 1 6 2 8 10 7

Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 1(e)(iii) in the evidence document.
[2]

© UCLES 2024 9618/43/M/J/24 [Turn over


6

2 A computer program will store data about trees.

The user can enter their requirements for a tree and a suitable tree will be selected.

The program is written using object‑oriented programming.

The class Tree stores data about the trees.

Tree
TreeName : STRING stores the name of the tree

HeightGrowth : INTEGER stores the number of cm the tree will grow each year

MaxHeight : INTEGER stores the maximum height in cm that the tree will grow

MaxWidth : INTEGER stores the maximum width in cm that the tree will grow

Evergreen : STRING stores whether the tree keeps its leaves as "Yes", or
loses its leaves as "No"
Constructor() initialises TreeName, HeightGrowth, MaxHeight,
MaxWidth and Evergreen to its parameter values

GetTreeName() returns the name of the tree

GetGrowth() returns the number of cm the tree will grow each year

GetMaxHeight() returns the maximum height in cm that the tree will grow

GetMaxWidth() returns the maximum width in cm that the tree will grow

GetEvergreen() returns whether the tree keeps its leaves or loses its
leaves

(a) (i) Write program code to declare the class Tree and its constructor.

Do not declare the other methods.

Use the appropriate constructor for your programming language.

All attributes must be private.

If you are writing in Python, include attribute declarations using comments.

Save your program as Question2_J24.

Copy and paste the program code into part 2(a)(i) in the evidence document.
[4]

© UCLES 2024 9618/43/M/J/24


7

(ii) The get methods GetTreeName(), GetGrowth(), GetMaxHeight(),


GetMaxWidth() and GetEvergreen() each return the relevant attribute.

Write program code for the get methods.

Save your program.

Copy and paste the program code into part 2(a)(ii) in the evidence document.
[3]

(b) The text file Trees.txt stores data about 9 trees.

The data in the file is stored in the format:

Tree name,Height growth each year,Maximum height,Maximum width,Evergreen

For example, the first row of data is:

Beech,30,400,200,No

The tree is a Beech. It can grow 30 cm each year. It has a maximum height of 400 cm.
It has a maximum width of 200 cm. It is not evergreen (it loses its leaves).

The function ReadData():

• creates an array of type Tree


• reads the data from the file
• raises an exception if the file is not found
• creates a new object of type Tree for each tree in the file
• appends each object to the array
• returns the array.

Write program code for ReadData().

Save your program.

Copy and paste the program code into part 2(b) in the evidence document.
[7]

© UCLES 2024 9618/43/M/J/24 [Turn over


8

(c) The procedure PrintTrees() takes a Tree object as a parameter and outputs the tree’s
name, height growth each year, maximum height, maximum width and whether it is evergreen.

The output message changes depending on whether it is evergreen.

If it is evergreen, it is in the format:

TreeName has a maximum height MaxHeight a maximum width MaxWidth and grows
HeightGrowth cm a year. It does not lose its leaves.

If it is not evergreen, it is in the format:

TreeName has a maximum height MaxHeight a maximum width MaxWidth and grows
HeightGrowth cm a year. It loses its leaves each year.

Write program code for PrintTrees().

Save your program.

Copy and paste the program code into part 2(c) in the evidence document.
[4]

(d) The main program calls ReadData(), stores the return value and calls PrintTrees() with
the first object in the returned array.

(i) Write program code for the main program.

Save your program.

Copy and paste the program code into part 2(d)(i) in the evidence document.
[2]

(ii) Test your program.

Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 2(d)(ii) in the evidence document.
[1]

© UCLES 2024 9618/43/M/J/24


9

(e) The procedure ChooseTree() takes an array of Tree objects as a parameter.

The procedure prompts the user to input their requirements for a tree.
The user needs to enter:

• the maximum height the tree can be in cm


• the maximum width the tree can be in cm
• whether they want the tree to be evergreen, or not evergreen.

A tree meets the requirements if:

• the tree’s maximum height is not more than the user’s input

and

• the tree’s maximum width is not more than the user’s input

and

• the tree matches their evergreen input.

The procedure creates a new array of all the Tree objects that meet all the requirements.

The procedure calls PrintTrees() for each Tree object that meets all the requirements. If
there are no trees that meet all the requirements, a suitable message is output.

(i) Write program code for ChooseTree().

Save your program.

Copy and paste the program code into part 2(e)(i) in the evidence document.
[6]

(ii) The procedure ChooseTree() needs amending. After the procedure has output the list
of trees that meet all the requirements, the procedure needs to:

• take as input the name of one of the trees that the user would like to buy from those
that meet all the requirements
• take as input the height of the tree in cm when it is bought
• calculate and output how many years it will take the tree to grow to its maximum
height.

For example, the user inputs the tree, Beech. The tree’s height is 40 cm when bought.
The tree will take 12 years to reach its maximum height of 400 cm.

Write program code to amend ChooseTree().

Save your program.

Copy and paste the program code into part 2(e)(ii) in the evidence document.
[2]

© UCLES 2024 9618/43/M/J/24 [Turn over


10

(iii) Write program code to amend the main program to call ChooseTrees().

Test your program with the following tree requirements:

• a maximum height of 400 cm


• a maximum width of 200 cm
• a tree that is evergreen (does not lose its leaves).

When asked for the tree selection, use the following data:

• first tree name entered is ‘Blue Conifer’


• starting height is 100 cm.

Take a screenshot of the outputs.

Save your program.

Copy and paste the screenshot into part 2(e)(iii) in the evidence document.
[2]

© UCLES 2024 9618/43/M/J/24


11

3 A program reads data from the user and stores the data that is valid in a linear queue.

The queue is stored as a global 1D array, QueueData, of string values. The array needs space for
20 elements.

The global variable QueueHead stores the index of the first element in the queue.
The global variable QueueTail stores the index of the last element in the queue.

(a) The main program initialises all the elements in QueueData to a suitable null value,
QueueHead to −1 and QueueTail to −1.

Write program code for the main program.

Save your program as Question3_J24.

Copy and paste the program code into part 3(a) in the evidence document.
[1]

(b) The function Enqueue() takes the data to insert into the queue as a parameter.

If the queue is not full, it inserts the parameter in the queue, updates the appropriate pointer(s)
and returns TRUE. If the queue is full, it returns FALSE.

Write program code for Enqueue().

Save your program.

Copy and paste the program code into part 3(b) in the evidence document.
[4]

(c) The function Dequeue() returns "false" if the queue is empty. If the queue is not empty, it
returns the next item in the queue and updates the appropriate pointer(s).

Write program code for Dequeue().

Save your program.

Copy and paste the program code into part 3(c) in the evidence document.
[3]

© UCLES 2024 9618/43/M/J/24 [Turn over


12

(d) The string values to be stored in the queue are 7 characters long. The first 6 characters are
digits and the 7th character is a check digit. The check digit is calculated from the first 6 digits
using this algorithm:

• multiply the digits in position 0, position 2 and position 4 by 1


• multiply the digits in position 1, position 3 and position 5 by 3
• calculate the sum of the products (add together the results from all of the multiplications)
• divide the sum of the products by 10 and round the result down to the nearest integer to
get the check digit
• if the check digit equals 10 then it is replaced with 'X'.

Example:

Data is 954123

Character position 0 1 2 3 4 5
Digit 9 5 4 1 2 3
Multiplier 1 3 1 3 1 3
Product 9 15 4 3 2 9

Sum of products = 9 + 15 + 4 + 3 + 2 + 9 = 42

Divide sum of products by 10: 42 / 10 = 4 (rounded down)

The check digit = 4. This is inserted into character position 6.

The data including the check digit is: 9541234

A 7‑character string is valid if the 7th character matches the check digit for that data. For
example, the data 9541235 is invalid because the 7th character (5) does not match the check
digit for 954123.

(i) The subroutine StoreItems() takes ten 7‑character strings as input from the user and
uses the check digit to validate each input.

Each valid input has the check digit removed and is stored in the queue using
Enqueue().
An appropriate message is output if the item is inserted. An appropriate message is
output if the queue is already full.

Invalid inputs are not stored in the queue.

The subroutine counts and outputs the number of invalid items that were entered.

StoreItems() can be a procedure or a function as appropriate.

Write program code for StoreItems().

Save your program.

Copy and paste the program code into part 3(d)(i) in the evidence document.
[6]

© UCLES 2024 9618/43/M/J/24


13

(ii) Write program code to amend the main program to:

• call StoreItems()
• call Dequeue()
• output a suitable message if the queue was empty
• output the returned value if the queue was not empty.

Save your program.

Copy and paste the program code into part 3(d)(ii) in the evidence document.
[1]

(iii) Test the program with the following inputs in the order given:

999999X
1251484
5500212
0033585
9845788
6666666
3258746
8111022
7568557
0012353

Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot into part 3(d)(iii) in the evidence document.
[2]

© UCLES 2024 9618/43/M/J/24


14

BLANK PAGE

© UCLES 2024 9618/43/M/J/24


15

BLANK PAGE

© UCLES 2024 9618/43/M/J/24


16

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 2024 9618/43/M/J/24

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy