Question 4

OCR Computer Science June 2019 Paper 1AS8 marks

On the specification

(a)
1.4 Data types, data structures and algorithms
(b)
1.4 Data types, data structures and algorithms
(c)
1.4 Data types, data structures and algorithms
(d)
1.4 Data types, data structures and algorithms
Question text

4 Stacks and queues are both data structures. (a) State which of a stack or queue would be considered as a ‘First In First Out’ data structure. [1] A stack is shown in Fig. 4.1 before a set of operations are carried out on it. (b) Draw what the stack shown in Fig. 4.1 would look like after the following operations: push("A"), push("B"), pop(), push("C"), pop(), push("D") X Y Z Before operations After operations Fig. 4.1 [2] Fig. 4.2 shows a stack in two states: State One and State Two. X Y A Z Z State One State Two Fig. 4.2 (c) List the operations needed to get the stack from State One to State Two. [3] A queue is shown in Fig. 4.3. (d) Draw what the queue shown in Fig 4.3 would look like after the following operations: enqueue("A"), enqueue("B"), dequeue(), enqueue("C"), dequeue(), enqueue("D") X Y Z Front Rear Before operations After operations Fig. 4.3 [2]