9618/23/O/N/22 question 4: worked solution (October/November 2022, 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. Q73 9618/23/O/N/22 original Q4 Structured · 10 marks 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 IDEA A 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 VIDEO ▶ Whole paper Video solution of the whole paper · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.