The implementation of a linked list uses an integer variable and a 1D array List of type Node. Record type Node is declared in pseudocode as follows: TYPE Node DECLARE Data : STRING DECLARE Pointer : INTEGER ENDTYPE The array List is declared in pseudocode as follows: DECLARE List : ARRAY[1:200] OF Node The linked list will operate as follows: • Integer variable HeadPointer will store the array index for the first node in the linked list. • The Pointer field of a node contains the index value of the next array element (the next node) in the linked list. • The value 0 is used as a null pointer.
- (a)(i)State why the value 0 has been selected as the null pointer.[1]
- (a)(ii)Give the range of valid values that could be assigned to variable HeadPointer.[1]
- (b)The array List will be initialised so that each node points to the following node. The last node will contain a null pointer. Complete the program flowchart to represent the algorithm for this operation. START[4]
- (c)An algorithm outputs the Data field from all nodes in the array List. The order the Data is output should be the same order it is stored in the linked list. Describe the algorithm in four steps. Do not use pseudocode statements in your answer.[4]
This question uses a diagram from the original paper, which isn't shown here. Open the full paper from the past papers archive to see it.
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2024). The mark or mark type is shown in brackets.
- [1] 0 is not a valid array / List index value // No 0th element in the array
- [1] 0 to 200
- [1] MP1 Use of variable as array index and initialisation to 1 / to first element of array
- [1] MP2 Loop for 199 / 200 iterations
- [1] MP3 Assign Index+1 to each pointer field in a loop
- [1] MP4 Assign 0 to 200th pointer field
- [1] MP1 Assign HeadPointer to ThisPointer / Current Pointer // Identify first node using headpointer
- [1] MP2 Loop the following until ThisPointer value is 0 (zero) / null pointer reached
- [1] MP3 Output data (field) from array element at index ThisPointer // Output data (field) of the current node / array element
- [1] MP4 Assign pointer field from current array element / index / to ThisPointer / Current Pointer // Assign pointer field from current node to ThisPointer / Current Pointer
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →