Past paper – A Level Computer Science (9618)

Cambridge International AS & A Level · 9618

Computer Science · Paper 43

May/June 2026 · 9618/43/M/J/26

Questions3
Marks75
TypeWritten

Answer on paper, open each mark scheme and give yourself marks, then open the Summary.

0 / 0Answer a question to start your score.
Saved 0
Advertisement
1
9618/43/M/J/26 · Question 1May/June 2026Paper 4321 marks
Loading question…
Question text

A program stores 15 strings in the 1D array DataArray
1
(a) Write program code to declare the global 1D array DataArray with space for 15
string elements.
Save your program as Question1_J26.
Copy and paste the program code into 1(a) in the evidence document.
[1]
(b) The procedure CreateArray() takes 15 strings as input from the user. Each input is
converted to lower case and stored in DataArray in the order input.
Write program code for CreateArray()
Save your program.
Copy and paste the program code into 1(b) in the evidence document.
[4]
(c) The procedure OutputArray() outputs the data in each element in DataArray on one
line with a space between each element.
Write program code for OutputArray()
Save your program.
Copy and paste the program code into 1(c) in the evidence document.
[2]
© Cambridge University Press & Assessment 2026
Write program code for the main program to call CreateArray() and
(d) (i)
then OutputArray()
Save your program.
Copy and paste the program code into 1(d)(i) in the evidence document.
[1]
(ii)
Test your program. Enter the following data for the inputs in the order given:
1
One
2
TWO
three
??
house
99987
popping
green
eleven
12
Twenty
THIRTY
16
Take a screenshot of the output(s).
Save your program.
Copy and paste the screenshot into 1(d)(ii) in the evidence document.
[1]
© Cambridge University Press & Assessment 2026
(e) The procedure FindWords() takes a string as input from the user and converts it to
lower case. The procedure counts and outputs the number of times the input is stored
in DataArray
Write program code for FindWords(). Do not use an in‑built function to count the number
of times the input is stored in DataArray
Save your program.
Copy and paste the program code into 1(e) in the evidence document.
[5]
The procedure SortLength() uses a bubble sort to order the elements in DataArray
(f)
(i)
into ascending order by the length of each string.
The bubble sort needs to be efficient and stop iterating as soon as it identifies that
DataArray is in the correct order.
Write program code for SortLength(). Do not use an in‑built function to sort the array
or check if the array is in the correct order.
Save your program.
Copy and paste the program code into 1(f)(i) in the evidence document.
[5]
Write program code to extend the main program by calling FindWords() then
(ii)
SortLength() then OutputArray()
Save your program.
Copy and paste the program code into 1(f)(ii) in the evidence document.
[1]
© Cambridge University Press & Assessment 2026
(iii)
Test your program. Enter the following data to be stored in the array in the order given:
one
One
1
three
three
One
house
99987
popping
green
eleven
One
Twenty
THIRTY
One
Enter "one" as the string to find in the array.
Take a screenshot of the output(s).
Save your program.
Copy and paste the screenshot into 1(f)(iii) in the evidence document.
[1]
© Cambridge University Press & Assessment 2026

2
9618/43/M/J/26 · Question 2May/June 2026Paper 4329 marks
Loading question…
Question text

2
A prototype for a game is being developed using Object‑Oriented Programming (OOP).
The game has a set of characters that have data stored about their characteristics, for example
if the character can fly or not fly. A user has to select their requirements, for example a character
that can fly, and the program will output the characters that meet the user’s requirements.
The class Character stores the data about the characters. The attributes are public.
Character
CharacterName : String
stores the character’s name
Colour : String
stores the colour of the character, for
example "Green"
SuperStrength : String
stores whether the character has super strength
("Yes") or not ("No")
Fly : String
stores whether the character can fly ("Yes") or
not ("No")
Invisible : String
stores whether the character can become
invisible ("Yes") or not ("No")
Constructor()
initialises the attributes to its parameter values
GetCharacterName()
returns CharacterName
GetColour()
returns Colour
GetSuperStrength()
returns SuperStrength
GetFly()
returns Fly
GetInvisible()
returns Invisible
Write program code to declare the class Character and its constructor.
(a) (i)
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program as Question2_J26.
Copy and paste the program code into 2(a)(i) in the evidence document.
[4]
© Cambridge University Press & Assessment 2026
The get methods GetCharacterName(), GetColour(), GetSuperStrength(),
(ii)
GetFly() and GetInvisible() each return the appropriate attribute.
Write program code for GetCharacterName(), GetColour(),
GetSuperStrength(), GetFly() and GetInvisible()
Save your program.
Copy and paste the program code into 2(a)(ii) in the evidence document.
[3]
(b) The text file Characters.txt stores data about 15 characters. Each character is on a new
line in the file. The data is stored in the order: Character name, colour, super strength, fly,
invisible. Each value is separated by a comma.
For example, the first line in the file is:
Jet,Black,Yes,No,No
The name of the character is Jet. The colour of the character is Black. The character has
super strength. The character cannot fly. The character cannot become invisible.
The function ReadData():
•
opens the file Characters.txt and reads in the data
•
creates a new Character object for each character in the file
•
stores each Character object in a local array
•
returns the populated array.
The function uses exception handling when opening and reading from the file.
Write program code for ReadData()
Save your program.
Copy and paste the program code into 2(b) in the evidence document.
[7]
© Cambridge University Press & Assessment 2026
(c) The procedure OutputCharacters() takes an array of Character objects as a
parameter. The procedure outputs the data for each character on a new line, in the format:
Name: <Character name> Colour: <Colour> Super strength: <Super
strength> Fly: <Fly> Invisible: <Invisible>
For example:
Name: Jet Colour: Black Super strength: Yes Fly: No Invisible: No
Write program code for OutputCharacters()
Save your program.
Copy and paste the program code into 2(c) in the evidence document.
[3]
The main program calls ReadData() and then OutputCharacters() with the
(d) (i)
returned array.
Write program code for the main program.
Save your program.
Copy and paste the program code into 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 2(d)(ii) in the evidence document.
[1]
© Cambridge University Press & Assessment 2026
(e) The main program needs to give the user two choices to limit the characters that they can
choose from. For example, they could choose to only see characters that are green and that
can fly.
(i)
The main program needs extending to:
•
prompt the user to enter two criteria and take both as input.

3
9618/43/M/J/26 · Question 3May/June 2026Paper 4325 marks
Loading question…
Question text

3
A binary tree is designed to store up to 100 positive integers. The binary tree stores data in
ascending numerical order.
The data in the binary tree is created as a global 2D array with the identifier BinaryTree
Each node has three values:
•
a pointer to the array index with the left node
•
the integer data
•
a pointer to the array index with the right node.
A null pointer is represented by the integer –1. All nodes are initialised with the null data –1
The table has example data for a binary tree:
index
left pointer
data
right pointer
0
1
20
2
1
4
10
–1
2
3
26
–1
3
–1
22
–1
4
–1
8
–1
The binary tree has two global pointers:
•
TreeRootPointer, initialised to –1, stores the index of the root node of the binary tree
•
FirstFreeNodePointer, initialised to 0, stores the index of the first node that does not
store any data.
Data cannot be removed or replaced from the tree. FirstFreeNodePointer is incremented
each time a node is added to the binary tree.
(a) The main program initialises all 100 nodes, TreeRootPointer
and FirstFreeNodePointer
Write program code for the main program.
Save your program as Question3_J26.
Copy and paste the program code into 3(a) in the evidence document.
[3]
© Cambridge University Press & Assessment 2026
(b) The procedure AddNode():
•
takes an integer parameter to be stored as the data in a new node
•
stores the data in the first element and updates the root pointer when the tree is empty
•
outputs "The tree is full" if the tree is full
•
stores the data in the next free node if the tree is not full, then:
◦
checks if the data is less than or greater than the root node
◦
follows the left or right pointer(s) repeatedly until it reaches the appropriate
leaf node
◦
updates the appropriate parent node pointer to the new node.
Write program code for AddNode()
Save your program.
Copy and paste the program code into 3(b) in the evidence document.
[7]
(c) The procedure OutputArray() outputs the content of the first 10 elements in the binary
tree. Each node is output on one line in the format:
<left pointer> <data> <right pointer>
For example:
1
20
4
Write program code for OutputArray()
Save your program.
Copy and paste the program code into 3(c) in the evidence document.
[2]
© Cambridge University Press & Assessment 2026
(d) (i)
Write program code to extend the main program to:
•
take 10 integers as input
•
store each input in the binary tree in the order they are entered using the
appropriate procedure
•
output the content of the binary tree using OutputArray()
Save your program.
Copy and paste the program code into 3(d)(i) in the evidence document.
[3]
(ii)
Test your program. Enter the following numbers in the order shown:
50
26
120
236
2
16
67
49
165
15
Take a screenshot of the output(s).
Save your program.
Copy and paste the screenshot into 3(d)(ii) in the evidence document.
[1]
© Cambridge University Press & Assessment 2026
(e) An in‑order tree traversal outputs the contents of the binary tree in ascending numerical
order by:
•
visiting the left node
•
output the data
•
visiting the right node.
For example, an in‑order traversal on the following binary tree will output: 5 12 18 20 26
20
12
26
5
18
The recursive procedure InOrder():
(i)
•
takes the root pointer as a parameter
•
makes a recursive call with the left pointer as the parameter if the left pointer is
not null
•
outputs the data at the parameter
•
makes a recursive call with the right pointer as the parameter if the right pointer is
not null.
Write program code for InOrder()
Save your program.
Copy and paste the program code into 3(e)(i) in the evidence document.
[7]
Write program code to extend the main program to call InOrder()
(ii)
Save your program.
Copy and paste the program code into 3(e)(ii) in the evidence document.
[1]
© Cambridge University Press & Assessment 2026
(iii)
Test your program. Enter the following numbers in the order given:
50
26
120
236
2
16

Advertisement