9618/22/O/N/23 question 3: worked solution (October/November 2023, paper 22)

Show as 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. Q77 9618/22/O/N/23 original Q3 Structured · 9 marks 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. Variable Value Start_Pointer 4 Free_List_Pointer 5 Start_Pointer = 4 [1] Index Data array Pointer array 1 D32 2 2 D11 3 3 D100 0 4 D40 1 5 F1 6 6 F2 7 7 F3 8 8 F4 0 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 IDEA A 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 VIDEO ▶ Starts at Q3 (16:07) Starts at Q3 (16:07) · by Pseudocode Pro. Tap the picture to open it on YouTube.