Question 3(d)(ii) 2024 · October-November · Paper 41 · 1 mark
Question 3
Part (d)
(ii)
Question 3
A linked list stores positive integer data in a 2D array. The first dimension of the array stores the
integer data. The second dimension of the array stores the pointer to the next node in the linked list.
an empty list. A pointer of –1 identifies that node as the last node.
The linked list can store 20 nodes.
The global 2D array LinkedList stores the linked list.
LinkedList is initialised as an empty list. The data in each node is initialised to –1. Each node’s pointer stores the index of the next node. The last node stores the pointer value –1, which indicates it is the last node.
The global variable FirstEmpty stores the index of the first element in the empty list. This is the first node in the empty linked list when it is initialised, which is index 0.
The global variable FirstNode stores the index of the first element in the linked list. There is no data in the linked list when it is initialised, so FirstNode is initialised to –1.
This diagram shows the content of the initialised array.
FirstEmpty = 0
FirstNode = –1
Index Data Pointer
0 -1 1
1 -1 2
2 -1 3
3 -1 4
4 -1 5
19 -1 -1 The procedure RemoveData() removes a node from the linked list.
The procedure takes the data item to be removed from the linked list as a parameter.
The procedure checks each node in the linked list, starting with the node FirstNode, until it finds the node to be removed. This node is added to the empty list, and pointers are changed as appropriate. The procedure only removes the first occurrence of the parameter.
Assume that the data item being removed is in the linked list.
(ii)
Amend the main program to:
- call RemoveData() with the parameter 5
- output the word "After"
- call OutputLinkedList().
Save your program.
Copy and paste the program code into part 3(d)(ii) in the evidence document.
Reveal official mark-scheme answer
Official answer for Question 3
Part (d)
(ii)
Question 1
mark for calling RemoveData(5), outputting "After", calling OutputLinkedList()
Question 1
Why this question appears here
82% assigned-topic match · Programming › Structured programming
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9618_w24_qp_41.pdf
