# Infix, Postfix and Prefix Notations/Expressions

Infix notation:

Example: (A+B)

Infix notation is commonly used in arithmetic formula or statements, the operators are written in-between their operands. An expression such as A * ( B + C ) / D is solved as:

• First add B and C.
• Multiply the result by A
• Divide result by D to give the final answer.

Infix notation needs order of precedence for binary operators. The precedence for main binary operators is mentioned below

1. ^
2. / *
3. + –

Note: brackets ( ) are used to override these rules.

Postfix Notation (Reverse Polish Notation):

Example: A B+

Operators are used after their operands for example to add 3 and 4, instead of writing 3 + 4 which is infix expression, postfix expression will be 3 4 +. The order of evaluation of operators is always left-to-right, and brackets cannot be used to change this order. Postfix expression of example above will be A B C + * D /. Operators act on values immediately to the left of them. This is also called as Polish postfix notation or simply postfix notation.