Solution Review: Prefix to Postfix Conversion

The solution to the 'Prefix to Postfix Conversion' challenge.

We'll cover the following


Before moving onto the code, let’s see the following steps to solve the problem:

  • Scan the expression from right to left. For every symbol, check whether it’s an operator or operand.
    • If it is an operand, push it into the stack.
    • If it is an operator, pop from the stack two times.
      • Concatenate the popped items and the operator.
      • Push the concatenated result into the stack.
  • When traversing through the expression is complete, the stack will hold one element only, i.e., the final result (the postfix expression).

Get hands-on with 1200+ tech skills courses.