Data types, records, arrays and abstract data types – A Level Computer Science (9618)

54 questions · page 1 of 4 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
1
9618/21/M/J/26 · Question 4May/June 2026Paper 214 marks
Loading question…
Question text

4
An algorithm is expressed as:
•
A user inputs a sequence of integer values.
•
The process will calculate the number of positive integers.
•
The user will input value 0 to indicate there are no more numbers to be input.
•
Output the number of positive integers after the terminating 0 is input.
Write a structured English description for this algorithm as a sequence of steps.
Do not include pseudocode statements in your description.
Your answer might not require all six steps shown.
step 1 …
…
step 2 …
…
step 3 …
…
step 4 …
…
step 5 …
…
step 6 …
…
[4]
© Cambridge University Press & Assessment 2026

2
9618/21/M/J/26 · Question 6May/June 2026Paper 2112 marks
Loading question…
Question text

6
Fence parts are manufactured by a number of similar machines. The length of the part must fall
within a certain range. Parts not within the length range are rejected.
The data for each rejected part forms a data packet made up of three data items, each separated
by the ‘/’ character delimiter. The format of a data packet is:
<length>/<machine ID>/<description of the fault>
•
The length is 3 digits (in millimetres).
•
The machine ID is a single character (‘A’, ‘B’, or ‘C’).
•
The description of the fault is a variable length string.
A pseudocode program will process the data for several data packets.
The program contains the statement:
"563/B/the fence length is too long"
DataPacket
(a) Complete the two pseudocode expressions which extract the appropriate data item.
…
PartLength
…
MachineID
[2]
(b) The program will create a module RejectDescription() to return the fault description.
Write the pseudocode for the module RejectDescription()
…
…
…
…
…
… [4]
© Cambridge University Press & Assessment 2026
,
,
(c) The data packets for all rejected parts are saved in this format in a text file Rejects.txt.
The file stores one data packet per line.
Write pseudocode to:
•
find all the rejected parts with a length greater than 560 millimetres and that were
produced on machine ‘B’ or machine ‘C’
•
output the description for each matching rejected part.
Your pseudocode will include a module call to RejectDescription() and the answers
given for 6(a).
…
…
…
…
…
…
…
…
…
…

3
9618/21/M/J/26 · Question 7May/June 2026Paper 2112 marks
Loading question…
Question text

7
Different data structures will be suitable for different computing applications.
(a) (i)
Identify a computing application where a queue data structure is suitable.
…
… [1]
(ii)
Justify why a queue is suitable for your application identified in 7(a)(i).
…
…
… [2]
(b) A programmer designs a circular queue.
•
The data items are stored in a 1D array, MyQueue
•
The queue is managed using two pointers.
The diagram shows the circular queue populated with four items.
MyQueue
"PIG"
Front
1
"DOG"
2
"RAT"
3
"SPIDER"
Rear
4
5
6
7
8
(i)
Write three pseudocode declaration statements to implement this circular queue.
1 …
2 …
3 …
[2]
© Cambridge University Press & Assessment 2026
,
,
(ii)
Two program modules are available to add and remove items to and from the queue.
module
description
EnQueue(<value>)
when <value> is added to the queue
DeQueue()
when an item is removed from the queue
Complete the state of MyQueue after the following sequence of changes:
•
DeQueue()
•
EnQueue("HORSE")
•
EnQueue("CAT")
MyQueue
1
2
3
4
5
6
7
8
[2]
© Cambridge University Press & Assessment 2026
,
,
(iii)
On a different occasion, the state of MyQueue is:
MyQueue
1
2
3
Front
"LION"
4
"GIRAFFE"
5
"TIGER"
6
"ANT"
Rear
7
8
Complete the state of MyQueue after the following sequence of changes:
•
EnQueue("GERBIL")
•
EnQueue("MONKEY")
•
EnQueue("SNAKE")
•
DeQueue()
MyQueue
1
2
3
4
5
6
7
8
[2]
© Cambridge University Press & Assessment 2026
,
,
(c) MyQueue will be initially empty.
Write a pseudocode procedure InitialiseQueue() to set up the empty MyQueue, using
a loop.
The initial array contents will be set to empty strings.
You are not required to repeat the declaration statements in 7(b)(i).
PROCEDURE InitialiseQueue()
…
…
…
…
…
…
…
ENDPROCEDURE
[3]
© Cambridge University Press & Assessment 2026
9618/2

Advertisement
4
9618/21/M/J/26 · Question 9May/June 2026Paper 2118 marks
Loading question…
Question text

9
A hotel has three floors numbered 0 to 2 (floor 0 is the ground floor). There are 15 rooms on
each floor.
The hotel gets many enquiries from customers to check if a room is available that day.
The availability data for that day is stored in a 2D array Version1
•
The first index is the floor number.
•
The second index is the room number.
•
On each of the three floors, the room numbers are 1 to 15.
Each cell of the array stores either:
•
‘A’ – the room is available
•
‘B’ – the room is already booked.
(a) Write the declaration statement for the 2D array Version1
… [2]
© Cambridge University Press & Assessment 2026
,
,
(b) An enquiry program will:
•
input a floor number
•
output all room numbers that are available on that floor
•
output the number of rooms that are available.
The output must be in the format shown in the two examples.
A wheelchair user makes an enquiry. She requires a room on the ground floor only.
Example program outputs:
Floor number: 0
0 room(s) available
There are no available rooms on
the ground floor.
Floor number: 0
Shows two rooms available on the
7
ground floor:
11
2 room(s) available
• rooms 7 and 11.
© Cambridge University Press & Assessment 2026
,
,
Write pseudocode for this enquiry program.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
© Cambridge University Press & Assessment 2026
,
,
(c) Customers are becoming more selective with their enquiries when searching for an
available room.
A new program design is required. It will create a record to define the data for a room.
Each room:
•
may have a sea view
•
is classified as: single room (‘S’), double room (‘D’) or family room (‘F’)
•
is either standard (‘ST’) or deluxe (‘DL’).
(i)
Complete the pseudocode.
TYPE RoomData
…

5
9618/22/M/J/26 · Question 3May/June 2026Paper 226 marks
Loading question…
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

6
9618/22/M/J/26 · Question 4May/June 2026Paper 229 marks
Loading question…
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]

7
9618/22/M/J/26 · Question 5May/June 2026Paper 2210 marks
Loading question…
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

8
9618/23/M/J/26 · Question 4May/June 2026Paper 234 marks
Loading question…
Question text

4
An algorithm is expressed as:
•
A user inputs a sequence of integers.
•
The user will input value –1 to indicate there are no more integers to be input.
•
The program will calculate the total number of integers greater than 120.
•
Output the total number of integers greater than 120 after the –1 terminator is input.
Write a structured English description for this algorithm as a sequence of steps.
Do not include pseudocode statements in your description.
Your answer might not require all six steps shown.
step 1 …
…
step 2 …
…
step 3 …
…
step 4 …
…
step 5 …
…
step 6 …
…
[4]
© Cambridge University Press & Assessment 2026

Advertisement
9
9618/23/M/J/26 · Question 6May/June 2026Paper 2313 marks
Loading question…
Question text

6
A linked list is an example of an Abstract Data Type (ADT).
A linked list is implemented using:
•
a 1D array for the data items
•
a 1D array for the link pointers
•
a start pointer.
The linked list maintains the data items in alphabetical order.
(a) The state of the linked list after five data items have been added is:
start pointer:
5
ANT
BISON
2
DOG
3
1
LEOPARD
ZEBRA
4
0
Complete the diagram to show the StartPointer and the contents of the arrays Data
and Pointer
StartPointer …
Data
Pointer
1
1
2
2
3
3
4
4
5
5
6
6
19
19
20
20
[3]
© Cambridge University Press & Assessment 2026
,
,
(b) State what the pointer value 0 (null pointer) indicates.
… [1]
(c) To maintain the linked list, algorithms are required to:
•
insert a new data item into the linked list
•
delete a data item from the linked list.
(i)
The data item ‘DOG’ is to be deleted from the linked list given in 6(a).
Complete the diagram to show the new state of the linked list.
start pointer:
ANT
BISON
DOG
LEOPARD
ZEBRA
[1]
(ii)
To delete a data item, the algorithm will have special cases. One special case is the
linked list is empty.
Describe two other special cases which must be considered when deleting a data item.
1 …
…
2 …
…
[2]
© Cambridge University Press & Assessment 2026
,
,
(d) The linked list given in 6(a) is repeated here. Data item ‘BAT’ is to be added to the linked list.
start pointer:
5
ANT
BISON
2
DOG
3
1
LEOPARD
ZEBRA
4
0
Describe how the data item ‘BAT’ is added to the linked list.
Do not attempt to write pseudocode.
…
…
…
…
…
…
…
…
…
…
…
…

10
9618/23/M/J/26 · Question 8May/June 2026Paper 2319 marks
Loading question…
Question text

8
A warehouse stores stock in bins. A bin is a container which stores the stock items; each bin can
store many identical items. The warehouse is organised on three different levels – level 0 (ground
level), then level 1 and level 2. Each level has 120 bins, numbered 1 to 120.
A bin is identified by the level and a bin number. The data item stored for each bin is a Boolean
value; this indicates whether the bin is in use (contains stock items) or not in use (contains no
stock items).
(a) (i)
Complete the pseudocode to declare a 2D array Bins
DECLARE …
[2]
(ii)
A pseudocode module InactiveReport() will produce a report that will show:
•
a header for each level
•
the bin number for each bin that is not in use on that level
•
the total number of bins that are not in use on all levels.
The module is initially developed for only five bins on each level.
An example program output:
Level: ground floor
Shows:
Bin 1
Bin 3
• the header for each level
Level: 1
Bin 4
• a list of bin numbers for bins that are
not in use on that level
Level: 2
Bin 1
• the total number of bins not in use.
Bin 2
Bin 5
6 bins are not in use
© Cambridge University Press & Assessment 2026
,
,
Complete the pseudocode for the procedure InactiveReport()
Assume that the Bins array is a global variable and has already been populated
with data.
PROCEDURE InactiveReport()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

11
9618/21/M/J/25 · Question 3May/June 2025Paper 218 marks
Loading question…
Question text

3
A student has been asked to create a simple guessing game program. This program will generate
a random integer value between 1 and 100. It will then repeatedly prompt the user to input an
integer value until they input the randomly generated value.
The student has written a structured English description:
step 1 – randomly generate an integer value between 1 and 100 inclusive
step 2 – prompt the user to input an integer value
step 3 – output an appropriate message if the value input was too high; then repeat from step 2
step 4 – output an appropriate message if the value input was too low; then repeat from step 2
step 5 – output an appropriate message if the value input was the same value that was randomly
generated; then end the program.
Write a pseudocode algorithm from this structured English description.
Assume no input validation is needed.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [8]
ĬÛĊ®Ġ´íÈõÏĪÅĊÝúµþ×

12
9618/21/M/J/25 · Question 4May/June 2025Paper 2128 marks
Loading question…
Question text

4
Study the algorithm:
DECLARE Chars : ARRAY[1:4] OF CHAR
DECLARE I, J : INTEGER
DECLARE Key : CHAR
2
I
'D'
Chars[1]
'T'
Chars[2]
'H'
Chars[3]
'R'
Chars[4]
WHILE I <= 4
//Outer loop
Chars[I]
Key
I – 1
J
WHILE J >= 0 AND Chars[J] > Key
//Inner loop
Chars[J]
Chars[J + 1]
J – 1
J
ENDWHILE
Key
Chars[J + 1]
I + 1
I
ENDWHILE
(a) The outer loop structure used in the algorithm is not the most appropriate one to use.
State the type of loop structure that would be the most appropriate to use and justify why it is
the most appropriate.
Loop structure …
Justification …
…
[2]
ĬÙĊ®Ġ´íÈõÏĪÅĊßüµĀ×
,
,
(b) Complete the trace table by dry running the algorithm.
The first row has been completed.
Chars
I
Key
J
Chars[J]
[1]
[2]
[3]
[4]
2
'D'
'T'
'H'
'R'
[6]
ĬÛĊ®Ġ´íÈõÏĪÅĊßúµĀ×

13
9618/21/M/J/25 · Question 5May/June 2025Paper 217 marks
Loading question…
Question text

5
Stacks and queues are both abstract data types.
A stack uses a top-of-stack pointer to indicate the location of the last item added to the stack.
A queue uses two pointers:
•
a front pointer to indicate the location of the next item to be removed from the queue
•
a rear pointer to indicate the location of the next item to be added to the queue.
A queue can be used to reverse the items stored on a stack.
For example, if a stack contains six items:
Initial state of the stack:
top-of-stack pointer
item 6
item 5
item 4
item 3
item 2
item 1
Final state of the stack when the items have been reversed:
top-of-stack pointer
item 1
item 2
item 3
item 4
item 5
item 6
Describe how the queue could be used to reverse the items that are currently stored on the stack.
Your description must include how the pointers are used in both the stack and queue.
Assume:
•
The stack initially contains an unknown number of items.
•
The queue can store all the items currently stored on the stack.
•
The queue is initially empty.
ĬÙĊ®Ġ´íÈõÏĪÅĊÞü·þ×
,
,
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

Advertisement
14
9618/21/M/J/25 · Question 6May/June 2025Paper 2112 marks
Loading question…
Question text

6
A program monitors the speed of vehicles as they move around a large building site.
Each vehicle contains a sensor which reads an integer value that represents the speed of the
vehicle. The value is expected to be in the range 0 to 60 inclusive.
The sensors cannot read values less than 0.
A program module has been written to validate the values read by the sensors.
(a) A test plan is needed to fully test the module.
Complete the table. The first line has been completed for you.
Assume the sensors generate only integer values.
Type of test data
Test data value
Expected outcome
normal
36
data item is accepted
[4]
(b) Each sensor used in the system has a unique sensor ID number in the range 1 to 50.
The program that is used to monitor the speed of each vehicle reads each sensor value
every second and stores this value along with the sensor’s unique ID into a global 2D array
Reading
The global array Reading has been declared as follows:
DECLARE Reading : ARRAY[1:2000, 1:2] OF INTEGER
The array contains 4000 elements organised as 2000 rows and 2 columns.
Column 1 contains the sensor value, and column 2 contains the sensor ID.
When 2000 sensor readings have been taken, the array is full and the system stops taking
any more sensor readings until the array has been processed.
A procedure Sort() is needed to sort the array into ascending order of sensor value using
an efficient bubble sort algorithm.
ĬÙĊ®Ġ´íÈõÏĪÅĊàü·Ā×
,
,
Write efficient pseudocode for the procedure Sort()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

15
9618/21/M/J/25 · Question 7May/June 2025Paper 2118 marks
Loading question…
Question text

7
A program is being developed to implement a customer loyalty scheme for a coffee shop.
The programmer has decided that the following data items need to be stored for each customer:
Data item
Description
customer ID
a unique six-digit string
an integer value that is increased by one for every cup of coffee the
points
customer orders
When a customer visits the shop and orders coffee, the scheme operates as follows:
•
The total number of points is increased by the number of coffees ordered.
•
If just one cup of coffee is ordered and the number of points goes above 10, then:
◦
the cup of coffee they have just ordered is given to them free of charge
◦
the number of points is reduced by 11.
•
If the order is for multiple coffees and the number of points goes above 10, then:
◦
they get one coffee free of charge for every 11 points
◦
the number of points is reduced by 11 for each free coffee.
For example, the:
•
customer currently has 9 points
•
customer orders 16 cups of coffee
•
total number of points now becomes 25
•
customer gets 2 free coffees and now has 3 points left.
The programmer has defined a program module that is called every time a customer places an
order:
Module
Description
•
called with two integer parameters:
◦
the number of coffees ordered
◦
CustomerOrder()
the current number of points
•
output a suitable message giving the number of free coffees
•
return a value for the new points total.
ĬÕĊ®Ġ´íÈõÏĪÅĊßù¶Ă×
,
,
(a) Write pseudocode for module CustomerOrder()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

Advertisement