Algirithm of postfix expression

1.declare all necessary variables
initialize an empty stack and result stack
2.scan the post fix expression character by character from left to right
if character is an operand push it into a stack
else
pop two operand from the result stack and store in operand 1 and operand 2
evaluate the expressikn applying the expression(operand 2 operator operand 1) and push it into the stack
3.repeat step until the end of post fix expression
4.pop the element in result stack
5.stop

No comments