✔ 最佳答案
Can you clarify the question a bit more? Are you asking about the stack used for the evaluation of the postfix string or the conversion from infix to postfix?
2010-10-19 08:00:37 補充:
I am assuming this is for evaluation of the postfix notation.
From the given infix notation, the postfix notation is: A B * C D E - / +
character: A
action: push A
stack: A
character: B
action: push B
stack: B
character: *
action: pop 2 values, compute and push the result back (R1= A*B)
stack: R1
character: C
action: push C
stack: R1 C
character: D
action: push D
stack: R1 C D
character: E
action: push E
stack: R1 C D E
character: -
action: pop 2 values, compute and push the result back (R2=D-E)
stack: R1 C R2
character: /
action: pop 2 values, compute and push the result back (R3=C/R2)
stack: R1 R3
character: +
action: pop 2 values, compute and push the result back (R4=R1+R2)
stack: R4
From above, your stack only needs a size of 4. (to store R1, C, D, E)
The procedure is in wiki:
http://en.wikipedia.org/wiki/Reverse_Polish_notation