1. turn postfix infix expression
Here, for manual changeover pair of chestnuts:
PS: The following are all red brackets add effects after!
Infix expression: (5 * 3 + 1 + 20) / 14
-
Operator Precedence by all operators and operands its parentheses (do not add the original parentheses)
( ( ( 5 + 20 ) + ( 1 * 3 ) ) / 14 ) -
The operator to move to the corresponding rear bracket (Note here that the change in parentheses)
( ( ( 520 ) + ( 13 ) *) + 14 ) / -
Remove the brackets
Postfix expression: + 13 520 +14 * /
2. postfix expression
Postfix expression is also called reverse Polish notation, which can be used in the evaluation process stack to secondary storage. Postfix expression is assumed to be evaluated as: 6523 * 8 + + + * 3, it is evaluated as follows:
- Traversal expression, digital encountered first placed on the stack, when the stack is as follows:
-
Then read "+", the pop-up 2 and 3, 3 + 2 performed, the calculation result is equal to 5, and 5 is pressed into the stack.
-
Read 8, which was directly placed on the stack.
-
Read, "*", and the pop-8 5, 8 * 5 performed, and the result is pushed onto the stack 40. Then a similar process, to read "+", the pop-up 40 and 5, the result 40 + 45 5 ... and so on into the stack. Finally, find the value of 288.