7 marksAbstract Data Types (ADTs)
CAPE Computer Science Unit 2 · 2014 · Paper 2 · Question 1(b)(i)
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.
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), Push(Stack, Z), Push(Stack, W), Mult(Stack), Add(Stack).
The mark scheme is shown once you've answered.
Practise this question