Skip to content
Related Articles

Related Articles

Why do we need Prefix and Postfix notations?

View Discussion
Improve Article
Save Article
  • Last Updated : 01 Jul, 2022

Prefix Notation:

Prefix notation is the notation in which operators are placed before the corresponding operands in the expression.

Example: 

Infix notation: A + B    
Prefix notation: +AB

Postfix Notation:

Postfix notation is the notation in which operators are placed after the corresponding operands in the expression.     

Example: 

Infix notation: A + B    
Postfix notation: AB+

Need of Prefix and Postfix Notations:

  • Prefix notations are needed when we require operators before the operands while postfix notations are needed when we require operators after the operands.
  • Prefix notations are used in many programming languages like LISP.
  • Prefix notations and Prefix notations can be evaluated faster than the infix notation.
  • Postfix notations can be used in intermediate code generation in compiler design.
  • Prefix and Postfix notations are easier to parse for a machine.
  • With prefix and postfix notation there is never any question like operator precedence.
  • There is no issue of left-right associativity.

Advantages of Postfix over Prefix Notations:

  • Postfix notation has fewer overheads of parenthesis. i.e., it takes less time for parsing.
  • Postfix expressions can be evaluated easily as compared to other notations.
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!