Infix to postfix converter
Convert an infix expression to postfix (Reverse Polish) or prefix notation the way ISC Computer Science marks it, with the stack after every symbol - or evaluate a postfix expression step by step.
Answer
- Postfix
- ABCDE^^*+
- Prefix
- +A*B^C^DE
Stack table
Scan left to right. An operand goes straight to the output. An operator first pops every operator of higher or equal precedence (^ is right to left, so an equal ^ stays), then is pushed. ( is pushed; ) pops up to its (. At the end the stack is emptied.
| Symbol scanned | Stack | Postfix expression | Action |
|---|---|---|---|
| A | (empty) | A | Operand: add it to the output |
| + | + | A | Push '+' |
| B | + | AB | Operand: add it to the output |
| * | +* | AB | Push '*' |
| C | +* | ABC | Operand: add it to the output |
| ^ | +*^ | ABC | Push '^' |
| D | +*^ | ABCD | Operand: add it to the output |
| ^ | +*^^ | ABCD | Push '^' |
| E | +*^^ | ABCDE | Operand: add it to the output |
| end | (empty) | ABCDE^^*+ | End: pop ^, ^, *, + to the output |
Practise on real ISC questions
- Convert the following infix notation to postfix form. ( A / B + C ) / ( D * ( E − F ) 2024 Specimen
- Convert the following infix notation to postfix notation: $A * (B + C / D) - E / F$ 2022 Specimen
- Convert the following infix expression to postfix form: $P * Q / R + (S + T)$ 2017
- Convert the following infix notation to postfix form: $A + ( B - C * ( D / E ) * F )$ 2018
- Convert the following infix notation to prefix form. $(P + Q / R) * (S + T / U) / V$ 2026 Improvement
- Convert the following infix notation to prefix notation. $(A - B) / C * (D + E)$ 2023
- Convert the following infix notation to postfix form. $(P + Q * R - S) / T * U$ 2024
- For the given Binary Tree, which traversal order will arrange the elements in ascending order? 2025 Practice
- Convert the following infix notation to prefix form: $(X + Y) / (Z * W / V)$ 2020
- Convert the following infix notation to postfix form. (AB^C) + (DE) where B^C = $B^C$ 2025 Improvement
More Computer Science tools
- Boolean algebra solver Simplify any expression: the laws step by step, truth table, K-map and the logic circuit.
- Binary tree and BST tool Build a binary search tree, rebuild a tree from two traversals, and get every traversal and fact.