Before writing should introduce a formidable Polish mathematician--jan Lukasiewicz (Rukasevichi), he thought of a kind of suffix expression that does not need parentheses, we in order to commemorate him, call it inverse Poland (Reverse Polish NOTATION,RPN) said.
We use the usual standard arithmetic expression, such as: + + (3-1) X3+10/2, called infix expression.
Put 9 3 1-3 * + 10 2/+ (here from the example of the infix expression on the previous line) this type of form that does not require parentheses is called a suffix expression, and is also a computational formula that the computer likes.
Conversion rules:
Each number and symbol of the infix expression is traversed from left to right, and if the number is output, it becomes part of the suffix expression, and if the symbol is the priority of the top symbol, the right parenthesis or precedence is lower than the top of the stack (multiplication precedence plus minus), the top element of the stack is sequentially out of the stack and the current symbol is Until the final output suffix expression.
Note: Left-to-right brackets are also added to the stack. Others follow the rules in and out of the stack.
The most important principle is the last-in-first-out of the stack, just the symbol as the element into the stack.
Written on December 24, 2014.
Infix expression-to-suffix expression