stack Java help
How can a stack be used to solve the following postfix expression:
3 4 * 15 2 4 / - +
Describe the rules to be followed as each character is read.
I don't understand what the problem is asking me to do. Can someone help me please understand and at least give me an idea on how to start
thanks for the help
Re: stack Java help
Postfix notation (also known as Reverse Polish Notation) works as follows. Keep pushing elements on the stack. When you get an operator, pop two elements off the stack and apply the operator. Push the result back on the stack. Continue the process until no more tokens. At the end, the top element should be the result.
4 5 3 - * would be evaluated as follows:
4 5 3 -
4 2 *