What are Prefix, Postfix and Infix Expression notations

In order to write any mathematical expression, few notations are being used in which Infix, Prefix and Postfix expressions are the most commonly used notations. Let’s look into these in more details to understand it better.

Infix Notation

This is the most common notation which we use generally in out writings. In this notation, mathematical operators (such as +, -, * etc.) are written in-between there operands. For eg:
A + B
X * Y
C / D

are the Infix notation examples.

Important points on Infix notation

  • Infix notation needs extra information to decide the order of evaluation of the operators.
  • Operator precedence are applicable in Infix notation
  • Brackets are allowed to override Operator Precedence rules.

Postfix notation (Reverse Polish notation)

In this notation, operators are written after there operands. For eg:
AB +
XY *
CD /

are the Postfix notation examples.

Important points on Postfix notation

  • Order of evaluation in Postfix notation is always left to right.
  • Brackets cann’t be used to override the orders.
  • Operators applied on the values present in the immediate left to them.

Prefix notation (Polish notation)

In this notation, operators are written before there operands. For eg:
+AB
*XY
/CD

are the Prefix notation examples.

Important points on Prefix notation

  • Order of evaluation in Prefix notation is always left to right.
  • Brackets can’t be used to override the orders.
  • Operators applied on the values present in the right to them and if these contains computations then these computations will be evaluated first which means order of evaluations will be changed.

Examples of Infix, Prefix and Postfix Notations

InfixPostfixPrefix
(A + B) * C + (D + E)(A B +) C * (D E +) ++* (+ A B) C (+ D E)
(A * B) + (C / D) – (E * F)( (A B *) (C D /) + (E F *) -)+ (*AB)-(/CD)(*EF)
A + B * C/(E – F)A B C * (E F -)/++ A * B / C (- E F)

Leave a Reply

Your email address will not be published. Required fields are marked *