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.
Prefix to Postfix conversion

  • Algorithm : 
    1. first we group the tokens from right to left
    2. 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

Popular posts from this blog

TREE

STACK

Evaluation of postfix expression