Quelpr

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

An algorithm processes a postfix expression expr with n characters using a stack stk.

Assuming stk is initially empty, determine the output of the provided algorithm when n is 9 and expr is '923*-82/+', and draw the stack on each iteration of the for loop.

The mark scheme is shown once you've answered.

Practise this question

Other parts of this question

  1. 1(a)(i)Describe how to implement the pop, push, and isEmpty stack operations for storing integers using static computer storage.[4 marks]
  2. 1(a)(ii)Write C code for a function implementing the push(Stack, data) operation for integer data, properly handling stack overflow conditions.[5 marks]
  3. 1(c)Explain how a stack can be used to determine if a string is a palindrome (e.g. 'madam').[6 marks]

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