Past paper – A Level Computer Science (9618)
Cambridge International AS & A Level · 9618
Computer Science · Paper 22
May/June 2026 · 9618/22/M/J/26
Answer on paper, open each mark scheme and give yourself marks, then open the Summary.
Question text
1
A program is being developed to control a simple alarm system to be used in a house. The alarm
has a control panel with a keypad and a screen to display text.
The keypad consists of 36 character keys:
•
26 upper‑case letter keys, allowing A to Z to be entered
•
10 digit keys, allowing 0 to 9 to be entered.
(a) When the alarm system is initially installed, a password must be created. When the
password is initially entered, it is checked to ensure that it follows a set of validation rules. It
is then permanently stored in the alarm system.
For a password to be valid it must follow these validation rules:
Rule 1: contain between six and eight characters inclusive.
Rule 2: contain at least one letter and one digit.
Rule 3: each character can only occur once.
The global variable Pass is used to store the password entered.
(i)
Complete the pseudocode to declare the variable to be used to hold the password.
DECLARE Pass : …
[1]
(ii)
Complete the pseudocode to check that a password contains between six and eight
characters inclusive (rule 1).
IF … (Pass) < 6 OR … (Pass) > … THEN
OUTPUT "Error"
OUTPUT "The password has to contain between 6 and 8 characters."
ENDIF
[2]
© Cambridge University Press & Assessment 2026
,
,
(iii)
Complete the pseudocode to check that a password entered contains at least one letter
and one digit character (rule 2).
DECLARE Index : INTEGER
DECLARE Character : CHAR
DECLARE LetterFlag, DigitFlag : …
FALSE
DigitFlag
…
LetterFlag
1 TO … (Pass)
FOR Index
… (Pass, … , … )
Character
IF … (Character) = TRUE THEN
…
DigitFlag
ELSE
…
LetterFlag
ENDIF
NEXT Index
IF … (LetterFlag AND DigitFlag) THEN
OUTPUT "Error"
OUTPUT "Password needs at least one letter and one digit."
ENDIF
[7]
(b) A state‑transition diagram is being created as part of the design process for the module,
which will control the alarm system once it has been successfully installed. Two of the states
already identified are that the alarm is in:
•
standby mode
•
on mode (alarm system is active).
(i)
Identify two other states that should be part of the state‑transition diagram.
1 …
2 …
[2]
© Cambridge University Press & Assessment 2026
,
,
(ii)
Two events that will cause a change of state are:
•
entering the password when the alarm system is in standby mode
•
entering the password when the alarm system is in on mode.
Identify three other events that would cause a change of state in the state‑transition
diagram for the alarm system.
1 …
2 …
3 …
[3]
(c) The validation rules from 1(a) are given again:
For a password to be valid it must follow these validation rules:
Rule 1: contain between six and eight characters inclusive.
Rule 2: contain at least one letter and one digit.
Rule 3: each character can only occur once.
Complete the table with test data that could be used to test the validation rules.
Each example of test data given must:
•
be invalid for the specific rule being tested
•
be valid for the other two rules not being tested
•
test a different aspect of the rule b
Question text
2
A new computer system is being developed to help manage a tool hire business. A customer can
specify if they want to hire a tool for either half a day or a full day.
An abstract model for the new system is required.
(a) Explain the purpose of abstraction.
…
… [1]
(b) State four items of data that must be stored each time a tool is hired.
item 1 …
item 2 …
item 3 …
item 4 …
[2]
(c) The computer system will have to process the tool hire data. One process is to cancel a tool
hire booking.
State two other processes that would be required.
process 1 …
…
process 2 …
…
[2]
© Cambridge University Press & Assessment 2026
Question text
3
A computer game uses a text file named WordList.txt containing 10 000 words, all in lower
case. Each word is unique and is stored on a separate line of the text file.
An efficient algorithm is needed to check that a word input by the user is stored in
WordList.txt. If the word is found, the line number where the word is stored must be output. If
the word is not found, the message "Not Found" must be output.
Complete the steps needed to describe the algorithm.
Do not include pseudocode statements in your answer.
The first three steps have been completed for you.
step 1: set line counter to 0
step 2: input a word
step 3: convert the word to lower case
…
…
…
…
…
…
…
…
…
…
…
[6]
© Cambridge University Press & Assessment 2026
Question text
4
A desktop web browser stores the history of web addresses visited.
The web browser uses a back button and forward button to move between web pages
recently visited.
Two stacks are used when each of these buttons are clicked:
•
back stack
•
forward stack.
The back button is clicked to return to a previously visited web page.
The back button operates as follows:
•
The web address currently being displayed by the browser is pushed onto the forward stack.
•
The web address from the top of the back stack is popped.
•
The web address popped is loaded by the web browser.
The forward button is clicked to revisit a web page previously visited.
The forward button operates as follows:
•
The web address currently being displayed by the browser is pushed onto the back stack.
•
The web address from the top of the forward stack is popped.
•
The web address popped is loaded by the web browser.
The current state of the two stacks:
back stack
forward stack
TOS
www.333.corp
TOS
www.111.home
www.zzz.corp
www.aaa.home
www.999.corp
www.ccc.my
www.222.me
The top of stack pointer is represented by TOS.
The current web address being displayed by the web browser is: www.bbb.home
The browsing session continues; the buttons are clicked in sequence in the three groups:
group 1:
back button
group 2:
forward button
group 3:
forward button
forward button
forward button
© Cambridge University Press & Assessment 2026
,
,
(a) Complete the diagrams to show the state of both stacks after each group of operations has
been performed.
Note: you must include the top of stack pointer (TOS) and the current web address being
displayed for each group diagram.
after group 1
back stack
forward stack
Web address currently displayed in the web browser: …
after group 2
back stack
forward stack
Web address currently displayed in the web browser: …
after group 3
back stack
forward stack
Web address currently displayed in the web browser: …
[6]
© Cambridge University Press & Assessment 2026
,
,
(b) A stack is an Abstract Data Type (ADT)
Identify one other ADT and describe two features of the ADT.
ADT …
feature 1 …
…
feature 2 …
…
[3]
Question text
5
A programmer has defined a global 1D array Numbers of type INTEGER, which can store 1000
integers. The lower bound of the array Numbers is set to 1. Each element of the array has been
initialised with a random integer in the range 200 to 99 999.
The programmer has written a bubble sort algorithm to sort the array Numbers into
ascending order.
Study algorithm A.
Assume all the variables have been correctly declared.
algorithm A:
1 TO 999
//Outer Loop
FOR LoopCounter
1 TO 999
//Inner Loop
FOR Index
IF Numbers[Index] > Numbers[Index + 1] THEN
//Start of block to swap neighbouring elements in the array
Numbers[Index]
Temp
Numbers[Index + 1]
Numbers[Index]
Temp
Numbers[Index + 1]
//End of block to swap neighbouring elements in the array
ENDIF
NEXT Index
NEXT LoopCounter
(a) Describe the change that would have to be made to the bubble sort algorithm (algorithm A)
so that the Numbers array would be sorted into descending order.
…
… [1]
© Cambridge University Press & Assessment 2026
,
,
(b) The programmer rewrites the bubble sort algorithm to make it more efficient.
Study algorithm B.
Assume all the variables have been correctly declared.
algorithm B:
999
Boundary
REPEAT
//Outer Loop
TRUE
NoSwaps
1 TO Boundary
//Inner Loop
FOR Index
IF Numbers[Index] > Numbers[Index + 1] THEN
//Start of block to swap neighbouring elements in the array
Numbers[Index]
Temp
Numbers[Index + 1]
Numbers[Index]
Temp
Numbers[Index + 1]
//End of block to swap neighbouring elements in the array
FALSE
NoSwaps
ENDIF
NEXT Index
Boundary ‑ 1
Boundary
UNTIL NoSwaps = TRUE
(i)
Explain why the second bubble sort algorithm (algorithm B) is more efficient than the
first bubble sort algorithm (algorithm A). Your answer must refer to both inner and
outer loops.
…
…
…
…
…
…
…
…
… [4]
(ii)
State the situation that will result in the outer loop iterating for the minimum number of
times when the second bubble sort algorithm (algorithm B) is used.
…
… [1]
© Cambridge University Press & Assessment 2026
,
,
(c) The programmer has defined a new procedure:
PROCEDURE Swap(Num1 : INTEGER, Num2 : INTEGER)
DECLARE Temp : INTEGER
Num1
Temp
Num2
Num1
Temp
Num2
END
Question text
6
A program is being developed to encrypt a message.
The following terms are used in the encryption technique to be used:
term
definition
plain text
The original message before it is encrypted.
cipher text
The encrypted version of the plain text.
The encryption method to be used is based on the algorithm for the Caesar Box Cipher. All plain
text messages to be encrypted must be 25 characters in length or less. If a message is less than
25 characters in length, then spaces are added to the end to make the padded plain text the
required length.
A square grid of five columns and five rows is used. The padded plain text message is put into
the grid row by row. The cipher text is obtained by reading the grid column by column.
For example:
plain text: This is a message
The number of characters in the original plain text, including spaces, is 17.
plain text with added spaces at the end: This∆is∆a∆message∆∆∆∆∆∆∆∆
The character ∆ is used to indicate a space in the padded plain text.
The grid filled, row by row, with the padded plain text.
T
h
i
s
∆
i
s
∆
a
∆
m
e
s
s
a
g
e
∆
∆
∆
∆
∆
∆
∆
∆
The cipher text is obtained by reading the grid column by column.
cipher text: Timg∆hsee∆i∆s∆∆sas∆∆∆∆a∆∆
The programmer has defined the first program module as:
module
description
•
user prompt for and input of plain text
•
check plain text contains between 1 and 25 characters inclusive
•
re‑input of plain text until it contains between 1 and 25 characters
AddPadding()
•
if required, additional space characters are added to the end of
the plain text to ensure it contains exactly 25 characters
•
return of amended plain text
© Cambridge University Press & Assessment 2026
,
,
(a) Write pseudocode for module AddPadding()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…