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

82 questions · page 1 of 6 · 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/41/M/J/26 · Question 1May/June 2026Paper 4126 marks
Loading question…
Question text

1
A program stores integer data in a linear queue.
The queue is created as a global 1D array with space for 10 elements.
The queue has a global head pointer, initialised to –1, that points to the first element in
the queue.
The queue has a global tail pointer, initialised to –1, that points to the last element in the queue.
(a) The main program initialises the 10 elements of the queue to –1 and initialises the
two pointers.
Write program code to declare the global variables and initialise the queue and its pointers.
Save your program as Question1_J26.
Copy and paste the program code into 1(a) in the evidence document.
[3]
(b) The function Enqueue() performs these tasks:
•
takes an integer parameter
•
checks if the queue is full
•
returns Boolean FALSE, if the queue is full
•
stores the parameter in the queue, updates the appropriate pointer(s) and returns
Boolean TRUE, if the queue is not full.
Write program code for Enqueue()
Save your program.
Copy and paste the program code into 1(b) in the evidence document.
[7]
© Cambridge University Press & Assessment 2026
(c) (i)
Write program code to extend the main program to:
•
take 11 integers as input from the user
•
use the appropriate function to insert each integer into the queue
•
output a message if at any point the queue is full
•
output the final content of the queue array. Do not dequeue the data.
You do not need to validate the data input.
Save your program.
Copy and paste the program code into 1(c)(i) in the evidence document.
[5]
(ii)
Test your program.
Enter the following data as input in the order given:
1
2
3
4
5
6
7
8
9
10
11
Take a screenshot of the output(s).
Save your program.
Copy and paste the screenshot into 1(c)(ii) in the evidence document.
[1]
© Cambridge University Press & Assessment 2026
(d) The function Dequeue():
•
returns –1 if the queue is empty
•
updates the pointer(s) and returns the next item from the queue if the queue is
not empty.
Write program code for Dequeue()
Save your program.
Copy and paste the program code into 1(d) in the evidence document.
[6]
(e) (i)
Write program code to amend the main program to:
•
take 6 integers as input from the user and store them in the queue using the
appropriate function
•
use the appropriate function to remove 4 elements from the queue
•
output each removed element from the queue.
Save your program.
Copy and paste the program code into 1(e)(i) in the evidence document.
[3]
(ii)
Test your program.
Enter the following data as input in the order given:
100
10
5
6
18
68
Take a screenshot of the output(s).
Save your program.
Copy and paste the screenshot into 1(e)(ii) in the evidence document.
[1]
© Cambridge University Press & Assessment 2026

12
9618/41/M/J/26 · Question 2May/June 2026Paper 4128 marks
Loading question…
Question text

2
A program stores data about toys that are made from bricks. The toys are stored in a record
structure with four fields:
•
ToyName: the string name of the toy
•
NumberBricks: the integer number of bricks in the toy
•
Difficulty: the string difficulty level of the toy (easy, medium or expert)
•
Category: the string category of the toy (for example town, display, play).
(a) Write program code to declare a record structure with the identifier ToyRecord and the
four fields.
Save your program as Question2_J26.
Copy and paste the program code into 2(a) in the evidence document.
[2]
(b) The text file Toys.txt stores data about 16 toys. Each toy is on a new line in the file. The
data is stored in the order: toy name, number of bricks, difficulty, category. Each value is
separated by a comma.
For example, the first line in the file is:
Fire Station,3981,Expert,Town
The name of the toy is Fire Station. The toy has 3981 bricks. The difficulty level is Expert.
The category is Town.
The function ReadData():
(i)
•
takes an array of type ToyRecord as a parameter
•
opens the file Toys.txt and reads in the data
•
creates a new record of type ToyRecord for each toy read from the file
•
stores each record in the parameter 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)(i) in the evidence document.
[8]
© Cambridge University Press & Assessment 2026
The procedure OutputToys() takes an array of type ToyRecord as a parameter and
(ii)
outputs the data for each toy in the array.
Write program code for OutputToys()
Save your program.
Copy and paste the program code into 2(b)(ii) in the evidence document.
[3]
(iii)
Write program code for the main program to:
•
declare an array of type ToyRecord with space for 16 elements
•
call the function ReadData() with the empty array and store the returned array
•
call OutputToys() with the returned array.
Save your program.
Copy and paste the program code into 2(b)(iii) in the evidence document.
[3]
(iv)
Test your program.
Take a screenshot of the output(s).
Save your program.
Copy and paste the screenshot into 2(b)(iv) in the evidence document.
[1]
(c) The program needs to allow a user to enter the difficulty level of a toy and then write all toys
that match that difficulty level to an external text file.
The function SearchToys():
(i)
•
takes an array of type ToyRecord as a parameter
•
prompts the user to enter the difficulty level
•
takes the difficulty level as input until it is valid
•
creates a new array containing the ToyRecord objects that match the difficulty
level input
•
returns the populated array.
Write program code for SearchToys()
Save your program.
Copy and paste the program code into 2(c)(i) in the evidence document.
[5]
© Cambridge University Press & Assessment 2026
The procedure WriteToys():
(ii)
•
takes an array of type ToyRecord as a parameter
•
creates and opens the file SelectedToys.txt to write
•
writes each record from ToyRecord to SelectedToys.txt with each field
separated by a comma and each record on a new line. For example:
<ToyName>,<NumberBricks>,<Difficulty>,<Category>
Write program code for WriteToys()
Save your program.
Copy and paste the program code into 2(c)(ii) in the evidence document.
[3]
(iii)
Write program code to extend the main program to:
•
call SearchToys() with the populated array and store the return array
•
call WriteToys() with the returned array.
Save your program.
Copy and paste the program code into 2(c)(iii) in the evidence document.
[2]
(iv)
Test your program. Enter the appropriate input for a medium difficulty level
when prompted.
Take one screenshot of the text file the program produces with the contents and
filename clearly visible.
Save your program.
Copy and paste the screenshot into 2(c)(iv) in the evidence document.
[1]
© Cambridge University

13
9618/42/M/J/26 · Question 1May/June 2026Paper 4218 marks
Loading question…
Question text

A program stores nine lower‑case strings in a 1D array TheData. The following strings are
1
stored in the order shown:
laptop
tablet
printer
computer
processor
monitor
memory
cable
touchscreen
(a) Write program code to declare the array TheData in the main program. Store the given
strings in the array.
Save your program as Question1_J26.
Copy and paste the program code into 1(a) in the evidence document.
[2]
The procedure FindLongestShortest():
(b) (i)
•
takes an array of strings as a parameter
•
finds and outputs the longest string in the array of strings
•
finds and outputs the shortest string in the array of strings.
All outputs must have appropriate messages. Do not use in‑built functions to find the
longest and shortest string in the array. You may use an in‑built length function to find
the length of a string.
You can assume that there will only be one string that has the shortest length.
You can assume that there will only be one string that has the longest length.
Write program code for FindLongestShortest()
Save your program.
Copy and paste the program code into 1(b)(i) in the evidence document.
[5]
© Cambridge University Press & Assessment 2026
Write program code to extend the main program to call FindLongestShortest()
(ii)
with TheData
Save your program.
Copy and paste the program code into 1(b)(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 1(b)(iii) in the evidence document.
[1]
The function InsertionSort():
(c) (i)
•
takes an array of strings as a parameter
•
sorts the strings in the array into ascending alphabetical order using an insertion sort
•
returns the sorted array.
The function must work for an array of any length. Do not use an in‑built function to sort
the array.
Write program code for InsertionSort()
Save your program.
Copy and paste the program code into 1(c)(i) in the evidence document.
[5]
(ii)
Write program code to extend the main program to perform the following in the
order shown:
•
output the string "Before sorting"
•
output the contents of the array TheData
•
call InsertionSort() with TheData as a parameter
•
output the string "After sorting"
•
output the contents of the returned sorted array.
Save your program.
Copy and paste the program code into 1(c)(ii) in the evidence document.
[3]
(iii)
Test your program
Take a screenshot of the output(s).
Save your program.
Copy and paste the screenshot into 1(c)(iii) in the evidence document.
[1]
© Cambridge University Press & Assessment 2026

Advertisement
14
9618/42/M/J/26 · Question 3May/June 2026Paper 4227 marks
Loading question…
Question text

A 2D array is used to store the linked list, LinkedList. The linked list stores a maximum of
3
eight data items. Each data item is an integer.
The array elements not currently used in the linked list are stored as the empty list.
LinkedList has two pointers:
•
StartLinkedList stores a pointer to the first node in the linked list
•
StartEmptyList stores a pointer to the first node in the empty list.
A data value of -1 indicates there is no data in the node.
A pointer of -1 indicates it is the end of the linked list, or the end of the empty list.
The linked list and pointers all have global scope.
The linked list already has the following data stored:
array index
data
pointer
0
9512
5
1
5541
3
2
1999
0
3
6651
–1
4
–1
6
5
5612
1
6
–1
–1
7
–1
4
StartLinkedList currently stores 2
StartEmptyList currently stores 7
(a) Write program code to declare and initialise the linked list and the pointers.
Save your program as Question3_J26.
Copy and paste the program code into 3(a) in the evidence document.
[5]
© Cambridge University Press & Assessment 2026
The procedure PrintListItems() outputs the data in each node of the linked list.
(b) (i)
The procedure starts with the first node in the linked list and follows the pointers until it
has reached the end of the linked list.
Write program code for PrintListItems()
Save your program.
Copy and paste the program code into 3(b)(i) in the evidence document.
[4]
The procedure PrintEmptyList() outputs the index of each node in the empty list.
(ii)
The procedure starts with the first node in the empty list and follows the pointers until it
has output the index of each node in the empty list.
Write program code for PrintEmptyList()
Save your program.
Copy and paste the program code into 3(b)(ii) in the evidence document.
[3]
(iii)
Write program code to extend the main program to:
•
output "Linked list" and then call PrintListItems()
•
output "Empty list" and then call PrintEmptyList()
Save your program.
Copy and paste the program code into 3(b)(iii) in the evidence document.
[2]
(iv)
Test your program.
Take a screenshot of the output(s).
Save your program.
Copy and paste the screenshot into 3(b)(iv) in the evidence document.
[2]
© Cambridge University Press & Assessment 2026
(c) New nodes are inserted at the end of the linked list.
The procedure AddItem() takes an integer parameter, inserts the parameter in the space
identified by StartEmptyList and updates the appropriate pointer(s).
If there is no space in the linked list, the procedure outputs "List is full"
Write program code for AddItem()
(i)
Save your program.
Copy and paste the program code into 3(c)(i) in the evidence document.
[8]
(ii)
Write program code to extend the main program to:
•
use AddItem() to insert a new node into the linked list with the data 8451
•
output the new contents of the linked list using PrintListItems() with a
suitable heading
•
output the new contents of the empty list using PrintEmptyList() with a
suitable heading.
Save your program.
Copy and paste the program code into 3(c)(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 3(c)(iii) in the evidence document.
[1]
© Cambridge University Press & Assessment 2026
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 (Cambridge University Press & Assessment) 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 our Copyright
Acknowledgements Booklet. This is produced for each series of examinations and is freely

15
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

Advertisement