DS – Algorithm to evaluate Postfix expression

Algorithm to evaluate Postfix expression:

  1. Scan the input from left to right.
  2. Move operands on to the Stack until any operator is found.
  3. If it is an operator, remove operands from stack, perform operation and store the result back to stack.
  4. Repeat this process until the end of expression has reached.

Expression:  8 2 / 3 + 4 8 * +

Scroll to Top