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

Q73 · 9618/23/O/N/22 Q4

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

Q739618/23/O/N/22original Q4Structured · 10 marks
Question 4 from 9618/23/O/N/22

Worked solution

(a)

The data type of the items to be stored (for example INTEGER) [1]

(b)(i)

Write two operations, each with its check:

Operation 1: Enqueue (add an item to the queue) [1]

Check 1: the queue is not full (there are unused elements in the array) [1]

Operation 2: Dequeue (remove an item from the queue) [1]

Check 2: the queue is not empty (there are items in the array) [1]

(b)(ii)

Any five of these:

Declare a 1D array of at least 10 elements with data type CHAR [1]

Declare an integer for the front of queue pointer [1]

Declare an integer for the end of queue pointer [1]

Declare an integer for the number of items in the queue (or the size of the queue) [1]

Initialise the pointers and count so the queue is empty [1]

KEY IDEAA queue needs an array, front and end pointers and a count, and each add or remove must first check for full or empty.
TOTAL 10 marks

Official mark scheme

Mark scheme for 9618/23/O/N/22 question 4
VIDEO
▶ Whole paper

Video solution of the whole paper · by Zafar Ali Khan (ZAK). 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.