Cambridge AS Level Computer Science 9618 · 10.4 Introduction to Abstract Data Types (ADT)

Q71 · 9618/21/O/N/22 Q4

Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 4 of 4.

Q719618/21/O/N/22original Q4Structured · 12 marks
Question 4 from 9618/21/O/N/22

Worked solution

(a)(i)

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]

(a)(ii)

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]

(a)(iii)

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]

(b)

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.

KEY IDEAA linked list keeps order with pointers, so inserting or deleting only changes pointers, but it costs extra memory for the pointers.
TOTAL 12 marks

Official mark scheme

Mark scheme for 9618/21/O/N/22 question 4
VIDEO
▶ 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.