Evaluating Postfix Expressions (Pseudocode)


This algorithm assumes that the given postfix expression is valid.


   get token
   while more tokens
      if token is an operand
         push token
      else
         pop into operand 2
         pop into operand 1
         perform the operation
         push result
      endif
      get token
   enddo
   pop answer


Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2008