Infix expression are those expression in which its form look like as a*b+c/d*e-f~g+h and Pre fix expression are those expression in which i...
Infix expression are those expression in which its form look like as a*b+c/d*e-f~g+h and Prefix expression are those expression in which its form/notation look like as abc*d-ef+*+gh~.It is used in c,c++,java,c#(or data structure) etc.
=++ga*-bcd(ans.)
Example(Direct/Shortcut Method):-
-->i+j*k/l-m~n+o
=i+(*jk)/l-m~n+o
=i+(/*jkl)-(~mn)+o
=(+i/*jkl)-(~mn)+o
=(-+i/jkl~mn)+o
=+-+i/jkl~mno....................Prefix Expression
Examples(by algorithm/stack method):-
-->g+a+(b-c)*d(written in backward direction)
Infix | Stack | Prefix |
---|---|---|
d | d | |
* | * | d |
) | *) | d |
c | *) | dc |
- | *)- | dc |
b | *)- | dcb |
( | * | dcb- |
+ | + | dcb-* |
a | + | dcb-*a |
+ | ++ | dcb-*a |
g | dcb-*ag++ |
=++ga*-bcd(ans.)
If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.
COMMENTS