Stack Operation Demonstration Program
An algebraic expression in reverse Polish notation is evaluated as follows.
-
The expression is scanned from left to right.
-
If a number is encountered, it is pushed onto the stack.
-
If an operator is encountered, it is applied to the top two operands
on the stack. After removing the operands used,
the result is pushed onto the stack.
-
When you provide an expression to be evaluated,
separate numbers and operators with spaces
as 10 20 + 2 * 30 4 6 + + *,
Source Code of the Polish Program
Source Code of the PolishG Program (Graphical Version)
Jacob's CS 261 Demos
Jacob's CS 261 Home