Cambridge AS Level Computer Science 9618 · 10.4 Introduction to Abstract Data Types (ADT)

Q74 · 9618/22/M/J/23 Q3

Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 4 of 4.

Q749618/22/M/J/23original Q3Structured · 10 marks
Question 3 from 9618/22/M/J/23

Worked solution

(a)(i)

The queue holds Red to Pink in locations 5 to 8, so there is space.

Check that the queue is not full [1]

The End of Queue pointer moves to location 9 [1]

Orange is stored in the location the End of Queue pointer points to (9) [1]

The End of Queue pointer then moves on to location 0 (it wraps round because the queue is circular) [1]

Also credited: Yellow is stored in location 0 (maximum 4 marks in total).

(a)(ii)

Front is at location 5 and End is at location 1. Items are in 5, 6, 7, 8, 9, 0, 1. Write: 7 [1]

(b)

Write the steps in words:

Open the file in READ mode [1]

Loop until the end of the file (EOF) so every line is processed [1]

The loop also ends when AddToQueue() returns FALSE, meaning the queue is full [1]

Read a line from the file inside the loop [1]

Pass the line (string) to AddToQueue() as the parameter [1]

KEY IDEAA circular queue moves its end pointer on and wraps to 0; a file loop ends at end of file or when the queue is full.
TOTAL 10 marks

Official mark scheme

Mark scheme for 9618/22/M/J/23 question 3
VIDEO
▶ Starts at Q3 (15:19)

Starts at Q3 (15:19) · by Pseudocode Pro. Tap the picture to open it on YouTube.

Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.