Question 6
OCR Computer Science June 2025 Algorithms and problem solving (H046-02)AS9 marks
On the specification
- (a)
- 1.4 Data types, data structures and algorithms
- (b)(i)
- 1.4 Data types, data structures and algorithms
- (b)(ii)
- 1.4 Data types, data structures and algorithms2.3 Algorithms
- (b)(iii)
- 2.3 Algorithms2.2 Problem solving and programming
Question text
6 Two data structures are a queue and a stack. (a) Describe one difference between a queue and a stack. [2] (b) The current contents of a stack created from an array called stack and pointer called topPointer are shown: index stack 7 6 5 4 3 2 13 1 21 0 10 The topPointer currently stores 2. (i) State the purpose of topPointer in the stack. [1] (ii) Describe the steps that will be followed to remove an item from the stack. [3] (iii) Complete the function to insert a new data item onto the stack. function push(dataItem) if topPointer 7 then return false else topPointer = stack[topPointer] = return true endif endfunction [3]