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

Q83 · 9618/22/M/J/25 Q6

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

Q839618/22/M/J/25original Q6Structured · 9 marks
Question 6 from 9618/22/M/J/25

Worked solution

(a)(i)

Work through the loop one pass at a time. Start with New = 8, Last = -1, Current = 2. Keep going while Data[Current] is less than 1043.

ValueStartUnusedNewLastCurrent
1043288-12
23
31
17
74

First row: 1043, 2, 8, 8, -1, 2 [1]

Last 2 and Current 3 (Data[2] = 1007 is less than 1043) [1]

Last 3 and Current 1 [1]

Last 1 and Current 7, then Last 7 and Current 4. The loop stops because Data[4] = 1056 is not less than 1043 [1]

(a)(ii)

Data[8] ← 1043. Pointer[8] ← Pointer[7] = 4. Pointer[7] ← 8. All other values stay the same.

IndexDataPointer
110187
210073
310101
410566
51092-1
610625
710348
810434
9010
100-1

Data row 8 contains 1043 [1]

Pointer row 7 contains 8 and Pointer row 8 contains 4 [1]

All other rows in both arrays unchanged [1]

(b)

The ADT is a linked list. [1]

Place() inserts a new value (node) into the linked list, in order. [1]

KEY IDEAFollow the pointers to find where the new value fits, then link the new node in between by changing two pointers.
TOTAL 9 marks

Official mark scheme

Mark scheme for 9618/22/M/J/25 question 6
VIDEO
▶ Whole paper

Video solution of the whole paper · by Awab Aqib. 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.