Explain what are Infix, Prefix and Postfix Expressions?

Technology CommunityCategory: StacksExplain what are Infix, Prefix and Postfix Expressions?
VietMX Staff asked 3 years ago
  • Infix expression notation requires that the operators appear between them in the expression
A + B
A + B * C
  • Prefix expression notation requires that all operators precede the two operands that they work on.
+ A B
+ A * B C
  • Postfix, on the other hand, requires that its operators come after the corresponding operands.
A B +
A B C * +

Note: Only infix notation requires the additional symbols like () to determine the order of operations . The order of operations within prefix and postfix expressions is completely determined by the position of the operator and nothing else. In many ways, this makes infix the least desirable notation to use. Infix notation is easy to read for humans, whereas pre-postfix notation is easier to parse for a machine.