What is Polish notation? Explain with an example.
2025
What is Polish notation? Explain with an example.
Show answer & explanation
Concept
Polish notation, also called prefix notation, places an operator before its operands. Because the operator appears first and each operator has a fixed arity, the expression can be interpreted without precedence rules or parentheses.
Application
Take the infix expression (A + B) × C.
Convert the parenthesized sum A + B to prefix form: + A B.
Place the multiplication operator before that result and C: × + A B C.
Reading from left to right, × receives the result of + A B as its first operand and C as its second operand.
Cross-check
With A = 2, B = 3, and C = 4, the prefix expression evaluates + A B to 5 and then × 5 C to 20. The original infix expression (2 + 3) × 4 also equals 20.
Therefore, Polish notation represents (A + B) × C as × + A B C.