Dijkstra's two-stack algorithm
Evaluate ( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
Algorithm
Maintain two stacks , push items to the stack based on the type of the encountered String or Value
Value: push onto the value stack.
Operator: push onto the operator stack.
Left parenthesis: ignore.
Right parenthesis: pop operator and two values; push the result of applying that operator to those values onto the operand stack.
Code
Last updated