Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 4 of 4.
Array indexes start at 1.
0 is not a valid index of List (there is no element 0), so it cannot be mistaken for a node [1]
HeadPointer is an index, or 0 if the list is empty.
0 to 200 [1]
The flowchart goes in this order:
START → box: SET Index TO 1 → decision: IS Index = 200 ?
Index set to 1 (a variable used as the array index) before the loop [1]
Loop that goes round 199 or 200 times, using the decision Index = 200 [1]
On NO: box SET List[Index].Pointer TO Index + 1, then box SET Index TO Index + 1, then back to the decision [1]
On YES: box SET List[Index].Pointer TO 0, then END [1]
Follow the pointers from the head, writing no pseudocode.
Step 1: Take the value in HeadPointer as the current pointer (the first node) [1]
Step 2: Repeat the next steps until the current pointer is 0 (the null pointer) [1]
Step 3: Output the Data field of the array element at the current pointer [1]
Step 4: Set the current pointer to the Pointer field of that element, then go back to Step 2 [1]
▶ Starts at Q3 (19:30)
Starts at Q3 (19:30) · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.