Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 4 of 4.
Explain the steps in order (any four of these six points score):
Check that there is a free node available in the free list [1]
Search the list for the correct place: B goes after A and before C [1]
Store the data value B in the first node of the free list [1]
Change the pointer of A so it points to the node containing B (instead of C) [1]
Other points that also score: set the pointer of B to point to the node containing C; move the start pointer of the free list on to the next free node.
Write either of these:
Use one 1D array to store the data and a second 1D array to store the pointers [1]
Use an integer variable for the start pointer and another integer variable for the next free pointer [1]
Alternative: define a record type with a data field and a pointer field and declare a 1D array of that type, plus the two integer variables.
▶ Whole paper
Video solution of the whole paper · by Papersdock. 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.