Polish Notation (Prefix Notation)
Polish Notation (Prefix Notation)
It refers to the notation in which the operator is placed before its two
operands. Here no parentheses are required, i.e.,
+AB
It refers to the analogous notation in which the operator is placed after its two
operands. Again, no parentheses is required in Reverse Polish notation, i.e.,
AB+
Stack-organized computers are better suited for post-fix notation than the
traditional infix notation. Thus, the infix notation must be converted to the
postfix notation. The conversion from infix notation to postfix notation must
take into consideration the operational hierarchy.
For example –
Here, we first perform the arithmetic inside the parentheses (A-B) and (D+E).
The division of C/(D+E) must be done prior to the addition with F. After that
multiply the two terms inside the parentheses and bracket.
2. Push the operands into the stack in the order they appear.
3. When any operator encounters then pop two topmost operands for
executing the operation.
For example –
Result: 60
6.