Prefix to Postfix, General Case
The key difference occurs when the next input is one of the operation symbols:
Pop and print operations off the stack until one of three things occur: (1) The stack becomes empty; (2) The next symbol on the stack is a left parenthesis; (3) The next symbol on the stack is an operation with lower precedence than the next input symbol. When one of these situations occur, stop popping, read the next input symbol, and push this symbol onto the stack.