Quelpr

CAPE Computer Science Unit 2 · 2014 · Paper 2 · Question 1(b)(ii)

In a searching application, the procedures Add or Mult pop the stack twice, add or multiply the popped values respectively, and push the result back onto the stack. Given X = 1, Y = 2, Z = 3, and W = 4.

State ONE condition that must exist for the Add and Mult procedures to work effectively.

The mark scheme is shown once you've answered.

Practise this question

Other parts of this question

  1. 1(a)(i)State whether a stack must exist prior to executing CreateStack.[1 mark]
  2. 1(a)(ii)State whether a stack must exist prior to executing DestroyStack.[1 mark]
  3. 1(b)(i)Determine the contents of the stack following the given sequence of procedure calls, showing all steps involved: Push(Stack, X), Push(Stack, Y), Add(Stack),…[7 marks]
  4. 1(b)(iii)Explain what will happen to the stack if the ADD operation is continuously applied to it.[2 marks]
  5. 1(c)(i)Explain the purpose of Enqueue() and Dequeue() in a FIFO queue.[5 marks]
  6. 1(c)(ii)Write an algorithm CountQueue using only the standard queue Abstract Data Type (ADT) operations that returns an integer count of the elements in the queue.[8 marks]

More practice: the rest of this paper · more Abstract Data Types (ADTs) questions · all CAPE Computer Science Unit 2 past papers