Prefix to Postfix conversion

  Prefix to Postfix conversion

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

  • Prefix expression: The expression of the form operator a b (+ab). When an operator is prefix by every pair of operands.
  • Postfix expression: The expression of the form a b operator (ab+). When an operator is followed by every pair of operands.
Prefix to Postfix conversion

  • Algorithm:
    1. first we group the tokens from right to left
    2. all operators move at the end of the 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