9618/21/M/J/21 question 6: worked solution (May/June 2021, paper 21)

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. Q67 9618/21/M/J/21 original Q6 Structured · 6 marks Worked solution (a) Explain the steps in order (any four of these six points score): Check that there is a free node available in the free list [1] Search the list for the correct place: B goes after A and before C [1] Store the data value B in the first node of the free list [1] Change the pointer of A so it points to the node containing B (instead of C) [1] Other points that also score: set the pointer of B to point to the node containing C; move the start pointer of the free list on to the next free node. (b) Write either of these: Use one 1D array to store the data and a second 1D array to store the pointers [1] Use an integer variable for the start pointer and another integer variable for the next free pointer [1] Alternative: define a record type with a data field and a pointer field and declare a 1D array of that type, plus the two integer variables. KEY IDEA Inserting into a linked list means taking a node from the free list, then changing two pointers; arrays and pointer variables can model it. TOTAL 6 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Papersdock. Tap the picture to open it on YouTube.