The Setup
Read the Prefix string Right-to-Left. Push operands as 1-character strings.
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
To convert Prefix to Postfix, we use a String Stack and read backwards. The logic is identical to Prefix-to-Infix, but we don't add parentheses and we put the operator at the end of the combined string.
Read the Prefix string Right-to-Left. Push operands as 1-character strings.
When you hit an operator, pop `val1` then `val2`. Combine them in pure Postfix format: `val1 + val2 + operator`.
Because we are outputting Postfix, we never add parentheses! The output string remains highly compressed.