Infix, Postfix, and Prefix notations are three different but equivalent ways of writing expressions.

Postfix, also known as Reverse Polish Notation (RPN), and Prefix, known as Polish Notation, are alternative formats.

  • Infix: Operators are placed between operands. Example: A + B
  • Postfix: Operators come after operands. Example: AB+
  • Prefix: Operators precede operands. Example: +AB

Here are additional examples:

Infix Postfix Prefix Notes
A * B + C / D A B * C D / + + * A B / C D Multiply A and B, divide C by D, then add the results.
A * (B + C) / D A B C + * D / / * A + B C D Add B and C, multiply by A, then divide by D.
A * (B + C / D) A B C D / + * * A + B / C D Divide C by D, add B, then multiply by A.