Prashnikaप्रश्निका

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.

What to do

Only needed when the postfix expression has letters.

Operators: + - * / % and ^ (power). Brackets ( ) [ ] { } work. Operands can be letters, names or numbers.

Try: (A + B) * C - D / EA + B * C ^ D ^ Eprefix of (P + Q) * (R - S)evaluate 5 6 2 + * 12 4 / -evaluate AB+C*

Answer

Value
37

Stack, symbol by symbol

An operand is pushed. An operator pops the top two values (the second popped is on the left), works them out and pushes the result.

SymbolStack (top on the right)Action
55Push 5
65, 6Push 6
25, 6, 2Push 2
+5, 8Pop 2 and 6; push 6 + 2 = 8
*40Pop 8 and 5; push 5 * 8 = 40
1240, 12Push 12
440, 12, 4Push 4
/40, 3Pop 4 and 12; push 12 / 4 = 3
-37Pop 3 and 40; push 40 - 3 = 37

Practise on real ISC questions

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.

All study tools ›