Recent Post

ARITHEMETIC EXPRESSION (infix , postfix , prefix)

1) Infix Notation
2) Prefix Notation
3) Postfix Notation

A + B     infix
+AB     prefix       Polish notation
AB+    Postfix       suffix or reverse polish notation

* Postfix notation is most suitable for a computer to calculate any expression (due to its reversing characteristic) and it is the universally accepted notation for designing ALU unit of CPU

* Postfix notation is the way computer looks towards any arithmetic expression 

* Any expression entered into the computer is first converted into postfix notation , stored in stack and then calculated.

Infix to Postfix Conversion:
Rules to be remembered during infix to postfix conversion
1) Parenthesize the expression stating from left to right.
2)  During parenthesize the expression the operands associated with operator having highest precedence are first parenthesized.
3) The sub-expression (part of expression) which has been converted into postfix is to be treated as single operand.
4) Once the expression is converted to postfix form remove the parenthesis.

Example to converted infix to postfix expression
   Question:

                  A + [ ( B + C ) + D + E ) * F ] / G
    Solution:

                A + [ ( B + C ) + D + E ) * F ] / G

          --> A + [ ( BC+ ) + ( DE+ ) * F ] / G

          --> A + [ (BC+) + (DE+F*)] / G

           --> A + [BC+DE+F*+]/G

           --> A +[BC+DE+F*+G/]

           --> A (BC+DE+F*+G/)+

           --> ABC+DE+F*+G/+




  

No comments