9618/23/M/J/25 question 2: worked solution (May/June 2025, paper 23)

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. Q84 9618/23/M/J/25 original Q2 Structured · 11 marks Worked solution (a)(i) The oldest value is at the bottom of the stack, and TopOfStack is at 403. 409 - 403 = 6 more pushes. Memory location of the value on the stack longest: 400 [1] Number of pushes to make TopOfStack 409: 6 [1] (a)(ii) Work through the operations. Push T (408), pop T, pop A (top is now 406 C), push Z (407), push X (408), pop X, push Y (408). Memory location Value 409 408 'Y' ← TopOfStack 407 'Z' 406 'C' 405 'F' 404 'K' 403 'B' 402 'S' 401 'R' 400 'D' TopOfStack points to 408 and 'Y' is in 408 [1] 'C' in 406 and 'Z' in 407 [1] 'F', 'K', 'B', 'S', 'R', 'D' unchanged in 405 to 400, and 409 empty [1] (b)(i) Put the names in alphabetical order: Earth, Jupiter, Mercury, Neptune, Saturn, Uranus. Each pointer holds the index of the next name. Index Data Pointer 0 "Neptune" 2 1 "Jupiter" 4 2 "Saturn" 5 3 "Earth" 1 4 "Mercury" 0 5 "Uranus" -1 Earth has pointer 1 [1] Uranus has pointer -1 [1] The other four pointers are correct (Jupiter 4, Mercury 0, Neptune 2, Saturn 5) [1] (b)(ii) Earth is first alphabetically and is at index 3, so StartPointer = 3 [1] (c) Any two of these: The first value added is the first value removed ( FIFO ) [1] Two pointers are needed, one for the start (front) and one for the end (rear) [1] It may work as a circular queue It is used with enqueue and dequeue operations KEY IDEA Know how a stack (last in, first out) and a linked list (pointers give the order) change, and that a queue is first in, first out. TOTAL 11 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Awab Aqib. Tap the picture to open it on YouTube.