Thursday, 17 January 2013

Infix to Postfix Conversion


By on 00:29

Infix expression are those expression in which its form look like as a*b+c/d*e-f~g+h and Postfix expression are those expression in which its form/notation  look like as abc*d-ef+*+gh~(Operator follow operands).It is used in c,c++,java,c#(or data structure) etc.

Example(Direct/Shortcut Method):-


-->i*(j+k*l)%m-n~(g+h)


=i*(jk+)/((lm*)-n)~o+p

=i*(jk+)/(lm*n-)~o+p
=i*(jk+)/(lm*n-o~)+p
=(ijk+*)/(lm*n-o~)+p
=(ijk+*lm*n-o~/)+p
=ijk+*lm*n-o~/p+......................Postfix Expression

Examples(by algorithm/stack method):-

-->i*(j+k*l)%m-n~(o+p)

Infix      Stack     Postfix
i
    i
*     *     i
(     *(     i
j     *(     ij
+     *(+     ij
k     *(+    ijk
*     *(+*    ijk
l     *(+*    ijkl
)     *    ijkl*+
%     %    ijkl*+*
m     %    ijkl*+*m
-     -    ijkl*+*-
n     -    ijkl*+*-n
~     -~    ijkl*+*-n
(     -~(    ijkl*+*-n
o     -~(    ijkl*+*-no
+     -~(+    ijkl*+*-no
p     -~(+    ijkl*+*-nop
)
   ijkl*+*-nop+~-



If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...