Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 4 of 4.
Follow the pointers: the list starts at D40 (index 4), then D32 (1), D11 (2), D100 (3). The free list starts at F1 (index 5), then F2 (6), F3 (7), F4 (8). A null pointer is shown as 0.
| Variable | Value |
|---|---|
| Start_Pointer | 4 |
| Free_List_Pointer | 5 |
Start_Pointer = 4 [1]
| Index | Data array | Pointer array |
|---|---|---|
| 1 | D32 | 2 |
| 2 | D11 | 3 |
| 3 | D100 | 0 |
| 4 | D40 | 1 |
| 5 | F1 | 6 |
| 6 | F2 | 7 |
| 7 | F3 | 8 |
| 8 | F4 | 0 |
Row 2 correct (D11, 3) [1]
Rows 3 and 4 correct (D100, null) and (D40, 1) [1]
Row 5 correct (F1, 6) [1]
Rows 7 and 8 correct (F3, 8) and (F4, null) [1]
A null pointer can be 0, Ø, or any index less than 1 or greater than 8.
Take the first free node (F1), put D6 in it, link it to D11, move the free pointer on, then link D32 to the new node.
Assign the data item D6 to F1 [1]
Set the pointer of this node to point to D11 [1]
Set Ptr2 to point to F2 [1]
Set pointer of D32 to point to D6 [1]
▶ Starts at Q3 (16:07)
Starts at Q3 (16:07) · by Pseudocode Pro. 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.