Evaluating a Postfix Expression Using a Stack Evaluating a Postfix Expression Using a Stack.
Postfix expression contains only binary operators and is a valid expression.
Scan RPN expression from left to right. When an operand is encountered, push it to the stack. When an operator is encountered, apply it to top two elements of the stack. When postfix expression has been exhausted, one element will remain on the stack. It is the result of the entire expression.