Prefix to Postfix Conversion
To convert a prefix to a postfix expression, we will use a stack to hold the operands. Whenever an operator is found, we pop two operands from the stack and push a new operand. The final element at the top of the stack will be our postfix expression.
Prefix to Postfix Examples:
Example: Convert Prefix Notation : *+AB-CD into postfix notation.
Steps of conversion :
We will travel from right to left and put operands in stack and when we find any operator take two operands from top and do the operation and put result on the stack in the end whatever expression is on the top of stack will be our result.
- *+AB-CD
- *+AB(CD-)
- *(AB+)(CD-)
- (AB+)(CD-)*
- AB+CD-*
Postfix Notation : AB+CD-*
Example : Convert prefix Notation *-A/BC-/AKL into postfix notation
Steps of Conversion:
- *-A/BC-(AK/)L
- *-A/BC((AK/)L-)
- *-A(BC/)((AK/)L-)
- *(A(BC/)-)((AK/)L-)
- (A(BC/)-)((AK/)L-)*
- ABC/-AK/L-*
Postfix Notation : ABC/-AK/L-*
Prefix to Postfix Converter Online
Prefix to Postfix Calculator is a free online tool to calculate the postfix of a prefix notation. In this converter user has to put the prefix notation in the input box and postfix notation will be displayed as a result.