Infix expression : A+(B*C-(D/E↑F)*ε)*H
- Put operands values in to output column
- Put non operands valued in to stack column
- On inserting closing parenthesis ‘)’ into stack POP and PUSH elements between ( ) to the output column from right to left scan.
- After scanning all the shymbols in expression, POP all the values from stack and PUSH in to output columns.
Symbol Scanned | Stack | Output | |
1 | A | A | |
2 | + | + | A |
3 | ( | +( | A |
4 | B | +( | AB |
5 | * | +(* | AB |
6 | C | +(* | ABC |
7 | – | +(- | ABC* |
8 | ( | +(-( | ABC* |
9 | D | +(-( | ABC*D |
10 | / | +(-(/ | ABC*D |
11 | E | +(-(/ | ABC*DE |
12 | ↑ | +(-(/↑ | ABC*DE |
13 | F | +(-(/↑ | ABC*DEF |
14 | ) | +(- | ABC*DEF↑/ |
15 | * | +(-* | ABC*DEF↑/ |
16 | ε | +(-*ε | ABC*DEF↑/ |
17 | ) | + | ABC*DEF↑/ε*- |
18 | * | +* | ABC*DEF↑/ε*- |
19 | H | +* | ABC*DEF↑/ε*-H |
20 | ABC*DEF↑/ε*-H*+ |
Postfix expression : ABC*DEF↑/ε*-H*+