Quelpr

CAPE Computer Science Unit 2 · 2014 · Paper 2 · Question 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.

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)(ii)State ONE condition that must exist for the Add and Mult procedures to work effectively.[1 mark]
  5. 1(b)(iii)Explain what will happen to the stack if the ADD operation is continuously applied to it.[2 marks]
  6. 1(c)(i)Explain the purpose of Enqueue() and Dequeue() in a FIFO queue.[5 marks]

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