Conversion of
Arithmetic Expressions
INFIX, PREFIX, AND POSTFIX NOTATIONS
Parihar Ansh Singh E-39
Panigrahy sidhesh E-37
Jay parab e-38
INTRODUCTION –
Arithmetic expressions can be
written in three different notations:
Infix, Prefix, and Postfix. These
notations define the order of
operators and operands, and each
has its advantages in computation
and readability.
INFIX NOTATION:
• In infix, operators are placed between
operands.
• Example : A + B * C
Prefix Notation (Polish Notation):
• In prefix notation, the operator comes before the
operands.
• Example : + A * B C
Postfix Notation (Reverse Polish Notation):
• In postfix notation, the operator comes after
the operands.
• Example : A B C * +
INFIX NOTATION
IT IS THE STANDARD NOTATION WHERE THE
OPERATOR IS PLACED BETWEEN THE OPERANDS.
THIS IS THE WAY ARITHMETIC EXPRESSIONS ARE
TYPICALLY WRITTEN IN EVERYDAY MATHEMATICS.
PREFIX NOTATION (POLISH NOTATION):
In prefix notation, also known as Polish
Notation, the operator appears before
the operands. This notation eliminates
the need for parentheses to denote
precedence because the position of the
operator directly determines the order of
operations.
POSTFIX NOTATION (REVERSE POLISH
NOTATION):
Postfix notation, also called Reverse Polish
Notation (RPN), places the operator after
the operands. Like prefix notation, postfix
eliminates the need for parentheses, relying
on the order of operands and operators to
determine the sequence of operations.
STEPS FOR CONVERSION:
1.Infix to →Postfix
• Operand :
Add to result.
• Left Parenthesis → Push to stack.
• Right Parenthesis → Pop from stack to result until Left Parenthesis is
encountered.
• Operator → Pop higher precedence operators from stack to result, then
push the operator.
2. Infix to Prefix :
• Reverse the infix expression.
• Convert reversed expression to postfix.
• Reverse the postfix result.
EXAMPLE OF CONVERSION :
Example without parentheses -
Example with parentheses -
Applications :
• Compilers use infix to postfix or prefix
conversion when parsing expressions.
• Calculators and expression evaluators
often rely on postfix or prefix notation to
process inputs efficiently.
• Mathematical logic and computational
theory involve these notations to simplify
operations and improve the evaluation
process.
Key concepts :
• Operator Precedence: Determines which operations are
performed first in infix expressions (e.g.,* before + ).
• Associativity: Defines how operators of the same precedence
are grouped (e.g., left to right for most operators).
• Use of Parentheses: In infix, parentheses are essential for
controlling operation order.
Conclusion :
• Infix is the most familiar and widely
used by humans but requires
parentheses to clarify the order of
operations.
• Prefix and Postfix notations are more
suited for computer processing, as they
eliminate the need for parentheses and
allow for efficient evaluation, often using
stack-based algorithms.
Thank you !