Hello Friends,
I am having trouble with a homework assignment and was wondering if you would please take a look at it for me.
I have to write a program that receives a prefix expression. Then it calculates and displays the result. It does this by using a stack to store values of sub-expressions as they are computed, and
another stack to store operators that have not yet been applied.
Does this mean that I have to have a stack for the results of the subexpressions and then a stack for each subexpression that has not been solved yet?
So I will have 1 stack of sub expressions before each is solved. Once the stack is made I can begin solving the subexpressions in the stack. I will solve the last one first and put the result in a new stack. I will solve the second to last one next and put the result on top of the same stack. I will do this to all sub expressions inside the stack. Once this is done I will begin working on all of the results in the second stack. Once the second stack is finished I will have the answer to the prefix expression.
Does this look correct?
Thank you,
Hank
S