Prefix to Infix conversion
Prefix to Infix conversion
================================================================================
- Infix expression: The expression of the form a operator b (a + b). When an operator is in-between every pair of operands.
- Prefix expression: The expression of the form operator a b (+ab). When an operator is prefix by every pair of operands.
- Algorithm :
- first we group the tokens from right to left
- all operators move in between two operands
- first we group the tokens from right to left
- all operators move in between two operands
- eg.
- - + / A ^ B C * D E * A C
- Solution:
- - + / A ^ B C * D E * A C
- - + / A B ^ C D * E A * C
- - + A / B ^ C D * E A * C
- - A / B ^ C + D * E A * C
- A / B ^ C + D * E - A * C
Comments
Post a Comment