0% found this document useful (0 votes)
6 views15 pages

Understanding Infix Notation

The document discusses different notations for representing mathematical expressions: infix, prefix, and postfix. In infix notation, operators are written between operands. In prefix notation, operators come before operands. In postfix notation, operators follow operands. Prefix and postfix notations do not require parentheses to define the order of operations, unlike infix notation. The document provides examples and explanations of how to convert between infix, prefix, and postfix notations.

Uploaded by

dollychugh2001
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views15 pages

Understanding Infix Notation

The document discusses different notations for representing mathematical expressions: infix, prefix, and postfix. In infix notation, operators are written between operands. In prefix notation, operators come before operands. In postfix notation, operators follow operands. Prefix and postfix notations do not require parentheses to define the order of operations, unlike infix notation. The document provides examples and explanations of how to convert between infix, prefix, and postfix notations.

Uploaded by

dollychugh2001
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

Prefix, Postfix, Infix Notation

By Mrs. Dolly Dhall,Asstt. Prof. , MCA Deptt., SPGOI, Rtk


Infix Notation
 To add A, B, we write
A+B
 To multiply A, B, we write
A*B
 The operators ('+' and '*') go in between
the operands ('A' and 'B')
 This is "Infix" notation.

By Mrs. Dolly Dhall,Asstt. Prof. , MCA Deptt., SPGOI, Rtk


Prefix Notation
 Instead of saying "A plus B", we could
say "add A,B " and write
+AB
 "Multiply A,B" would be written
*AB
 This is Prefix notation.

By Mrs. Dolly Dhall,Asstt. Prof. , MCA Deptt., SPGOI, Rtk


Postfix Notation
 Another alternative is to put the
operators after the operands as in
AB+
and
AB*
 This is Postfix notation.

By Mrs. Dolly Dhall,Asstt. Prof. , MCA Deptt., SPGOI, Rtk


Pre A In B Post
 The terms infix, prefix, and postfix tell
us whether the operators go between,
before, or after the operands.

By Mrs. Dolly Dhall,Asstt. Prof. , MCA Deptt., SPGOI, Rtk


Parentheses
 Evaluate 2+3*5.
 + First:
(2+3)*5 = 5*5 = 25
 * First:
2+(3*5) = 2+15 = 17
 Infix notation requires Parentheses.

By Mrs. Dolly Dhall,Asstt. Prof. , MCA Deptt., SPGOI, Rtk


What about Prefix Notation?
 +2*35=
=+2*35
= + 2 15 = 17
 * +235=
=*+235
= * 5 5 = 25
 No parentheses needed!

By Mrs. Dolly Dhall,Asstt. Prof. , MCA Deptt., SPGOI, Rtk


Postfix Notation
 235*+=
=235*+
= 2 15 + = 17
 23+ 5*=
=23+5*
= 5 5 * = 25
 No parentheses needed here either!

By Mrs. Dolly Dhall,Asstt. Prof. , MCA Deptt., SPGOI, Rtk


Conclusion:
 Infix is the only notation that requires
parentheses in order to change the order
in which the operations are done.

By Mrs. Dolly Dhall,Asstt. Prof. , MCA Deptt., SPGOI, Rtk


Fully Parenthesized Expression
 A FPE has exactly one set of Parentheses
enclosing each operator and its operands.
 Which is fully parenthesized?
(A+B)*C
( ( A + B) * C )
( ( A + B) * ( C ) )

By Mrs. Dolly Dhall,Asstt. Prof. , MCA Deptt., SPGOI, Rtk


Infix to Prefix Conversion
Move each operator to the left of its
operands & remove the parentheses:
( ( A + B) * ( C + D ) )

By Mrs. Dolly Dhall,Asstt. Prof. , MCA Deptt., SPGOI, Rtk


Infix to Prefix Conversion
Move each operator to the left of its
operands & remove the parentheses:
(+A B *(C+D))

By Mrs. Dolly Dhall,Asstt. Prof. , MCA Deptt., SPGOI, Rtk


Infix to Prefix Conversion
Move each operator to the left of its
operands & remove the parentheses:
*+A B (C+D)

By Mrs. Dolly Dhall,Asstt. Prof. , MCA Deptt., SPGOI, Rtk


Infix to Prefix Conversion
Move each operator to the left of its
operands & remove the parentheses:
*+A B +C D

Order of operands does not change!

By Mrs. Dolly Dhall,Asstt. Prof. , MCA Deptt., SPGOI, Rtk


Infix to Postfix
(((A+B)*C)-((D+E)/F))

A B+C* D E+F/-
 Operand order does not change!
 Operators are in order of evaluation!

By Mrs. Dolly Dhall,Asstt. Prof. , MCA Deptt., SPGOI, Rtk

You might also like