Question 4

OCR Computer Science June 2024 Algorithms and programming (H446-02)A level6 marks

On the specification

(a)
1.4 Data types, data structures and algorithms
(b)
1.4 Data types, data structures and algorithms2.3 Algorithms
(c)
1.4 Data types, data structures and algorithms
Question text

4 The current contents of a queue data structure are shown in Fig. 4. Fig. 4 20 15 3 2 headPointer tailPointer (a) State the purpose of headPointer and tailPointer in the queue shown in Fig. 4. headPointer tailPointer [2] (b) enqueue will add data to the queue. dequeue will remove data from the queue. Show the contents of the queue and the position of both pointers after the following actions have been executed on the queue shown in Fig. 4 in the order given: • enqueue(20) • dequeue() • dequeue() [2] (c) The queue is used to store ID numbers of jobs that a program needs to process. Some jobs will be given a priority which means they need to be processed first. Explain why this queue is not a suitable data structure for this program. [2]