9618/33/O/N/25 question 10: worked solution (October/November 2025, paper 33)

Show as plain text

Cambridge A2 Level Computer Science 9618 · 19.1 Algorithms Worked solution from the Computational thinking and Problem-solving Paper 3 Advanced Theory booklet, Part 1 of 2. Q24 9618/33/O/N/25 original Q10 Structured · 6 marks Worked solution (a) Declare a constant for the size, two integer pointers (bottom and top) and a string array of 100 items. CONSTANT Maximum = 100 DECLARE Base : INTEGER DECLARE Top : INTEGER DECLARE StackArray : ARRAY[1:100] OF STRING Constant Maximum = 100 declared correctly [1] Both pointers Base and Top declared as INTEGER [1] Array StackArray declared with 100 elements of type STRING [1] (b) Write a procedure that sets both pointers to starting values for an empty stack. PROCEDURE InitialiseStack() Base ← 0 Top ← 0 ENDPROCEDURE Correct procedure structure (PROCEDURE ... ENDPROCEDURE) [1] Base set to a suitable value (0 or 1) [1] Top set to a suitable value (-1, 0 or 1) [1] The values must fit the array bounds you declared in part (a). KEY IDEA A stack needs a constant size, two pointers and an array, and the pointers start at values that mean empty. TOTAL 6 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by rjmcompsci. Tap the picture to open it on YouTube.