9618/23/O/N/24 question 3: worked solution (October/November 2024, paper 23)
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. Q81 9618/23/O/N/24 original Q3 Structured · 10 marks 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 IDEA A 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 VIDEO ▶ Starts at Q3 (19:30) Starts at Q3 (19:30) · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.