Recursive Algorithm for Postfix/Infix expressions
807589Nov 19 2008 — edited Nov 19 2008For those that are unaware if infix is an expression like (5 + (3 * 2)) or (3 + 5) * 10, then the respective postfix expressions are 5 3 2 * + and 3 5 + 10 *.
Basically I need to do two things if given a postfix expression: 1) determine if it's a valid postfix expression, and 2) if so, evaluate it.
Now, I can (and did) do this with stacks easily. Very easy to understand with stacks. However, I need to do both using recursion, not stacks.
I've tried to work out some kind of algorithm but what i'm doing just isn't working. Can someone help with the necessary algorithm needed for both methods? tia