Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 4 of 4.
Draw new nodes for 'A' and 'K', leave out 'J' and 'L', and change only the pointers. The list in order is A, C, K.
Draw a new node holding 'A' and a new node holding 'K' [1]
Draw the Start pointer pointing to node 'A' [1]
Draw the pointer from node 'A' to node 'C', and from node 'C' to node 'K' [1]
Draw a null pointer (Ø) in node 'K'; the nodes 'J' and 'L' have no pointers to them [1]
Write two points:
In a linked list the pointers decide the order, so only pointers need to change when data changes [1]
It is easier to add and delete items and keep the right order; in an array other items must be moved along [1]
Write two points:
Extra memory is needed to store the pointers as well as the data [1]
A linked list is more complex to set up and program [1]
Any four of these:
Declare two 1D arrays [1]
One array holds the data and the other holds the pointers [1]
Elements with the same index together make one node [1]
A variable (INTEGER) for the start pointer, which gives the index of the first node [1]
Other accepted points: a value for the null pointer (for example 0 or -1), a free list pointer to unused nodes, and routines to add, delete and search.
Alternative: define a record type with a data field and a pointer field, then declare one array of that record type.
▶ Whole paper
Video solution of the whole paper · 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.