Question 3

OCR Computer Science June 2019 Paper 2AS11 marks

On the specification

(a)
1.4 Data types, data structures and algorithms
(b)(i)
1.4 Data types, data structures and algorithms2.3 Algorithms
(b)(ii)
2.2 Problem solving and programming
(b)(iii)
2.3 Algorithms
Question text

3 The current contents of a queue, colours, implemented in an array is shown in Fig. 3.1. red yellow green blue grey front = 0 end = 4 Fig. 3.1 (a) Describe the purpose of front and end. [2] (b) The queue has the subprograms enqueue and dequeue. The subprogram enqueue is used to add items to the queue and the subprogram dequeue removes items from the queue. (i) Use the following diagram to show the queue shown in Fig. 3.1 after the following program statements have run: enqueue("orange") dequeue() enqueue("maroon") dequeue() dequeue() front = end = [4] (ii) enqueue and dequeue are both functions. State the difference between a procedure and a function. [1] (iii) Describe the steps involved in the enqueue algorithm. [4]