Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Recursive Algorithm for Postfix/Infix expressions

807589Nov 19 2008 — edited Nov 19 2008
For 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 17 2008
Added on Nov 19 2008
14 comments
1,513 views