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

Q77 · 9618/22/O/N/23 Q3

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

Q779618/22/O/N/23original Q3Structured · 9 marks
Question 3 from 9618/22/O/N/23

Worked solution

(a)

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.

VariableValue
Start_Pointer4
Free_List_Pointer5

Start_Pointer = 4 [1]

IndexData arrayPointer array
1D322
2D113
3D1000
4D401
5F16
6F27
7F38
8F40

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.

(b)

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]

KEY IDEAA linked list in arrays uses index numbers as pointers, with 0 or an out-of-range value as null.
TOTAL 9 marks

Official mark scheme

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