An prefix expression is a expression in which first operator comes and proceded by strings. Every prefix string longer than a single variable contains first and second operands followed by an operator.e.g. A,+A B ,*A B ,+ * A B/ C D.
An postfix expression (also called Reverse Polish Notation) is a single letter or an operator, preceded by two postfix strings. Every postfix string longer than a single variable contains first and second operands followed by an operator.e.g. A,A B +,A B + C D –
First,Read the Prefix expression in reverse order (from right to left)
1.If the symbol is an operand, then push it into the Stack
2.But if the character is an operator, pop the top two values from stack.
3.Create a string by concatenating the two operands and the operator between them. string = (2nd top value+1st top value+operator)
4.And push the resultant string back to Stack Repeat the above steps until end of Prefix expression..Checkout examples that are mention below in table.And you can also check postfix to prefix Converter and postfix to posfix Converter .Checkout examples that are mention below.
Since some compilers,editors calculators convert expression to postfix to evaluate an expression. That's why if it has prefix expression that should be converted to postfix due to their further evaluation. So,this type of converter can be helpful in such cases.