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

Q81 · 9618/23/O/N/24 Q3

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

Q819618/23/O/N/24original Q3Structured · 10 marks
Question 3 from 9618/23/O/N/24

Worked solution

(a)(i)

Array indexes start at 1.

0 is not a valid index of List (there is no element 0), so it cannot be mistaken for a node [1]

(a)(ii)

HeadPointer is an index, or 0 if the list is empty.

0 to 200 [1]

(b)

The flowchart goes in this order:

START → box: SET Index TO 1 → decision: IS Index = 200 ?

Index set to 1 (a variable used as the array index) before the loop [1]

Loop that goes round 199 or 200 times, using the decision Index = 200 [1]

On NO: box SET List[Index].Pointer TO Index + 1, then box SET Index TO Index + 1, then back to the decision [1]

On YES: box SET List[Index].Pointer TO 0, then END [1]

(c)

Follow the pointers from the head, writing no pseudocode.

Step 1: Take the value in HeadPointer as the current pointer (the first node) [1]

Step 2: Repeat the next steps until the current pointer is 0 (the null pointer) [1]

Step 3: Output the Data field of the array element at the current pointer [1]

Step 4: Set the current pointer to the Pointer field of that element, then go back to Step 2 [1]

KEY IDEAA linked list in an array uses 0 as a null pointer because index 0 does not exist; follow pointers until you reach 0.
TOTAL 10 marks

Official mark scheme

Mark scheme for 9618/23/O/N/24 question 3
VIDEO
▶ Starts at Q3 (19:30)

Starts at Q3 (19:30) · by Zafar Ali Khan (ZAK). 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.