Postfix to Prefix conversion

   Postfix to Prefix conversion

================================================================================

  • Postfix expression: The expression of the form a b operator (ab+). When an operator is followed by 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.
Postfix to Prefix

  • Algorithm:
    1. first we group the tokens from left to right
    2. all operators move at the beginning of group

  • 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