9618/22/M/J/25 question 6: worked solution (May/June 2025, paper 22)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 10.4 Introduction to Abstract Data Types (ADT) Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 4 of 4. Q83 9618/22/M/J/25 original Q6 Structured · 9 marks 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. Value Start Unused New Last Current 1043 2 8 8 -1 2 2 3 3 1 1 7 7 4 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. Index Data Pointer 1 1018 7 2 1007 3 3 1010 1 4 1056 6 5 1092 -1 6 1062 5 7 1034 8 8 1043 4 9 0 10 10 0 -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 IDEA Follow 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 VIDEO ▶ Whole paper Video solution of the whole paper · by Awab Aqib. Tap the picture to open it on YouTube.