How many PUSH and POP operations will be needed to evaluate the following expression by reverse polish notation in a stack machine (A × B) + (C × D/E)?
Show answerHide answer
Correct answer: (B) 5 PUSH and 4 POP instructions
Explanation
The postfix form of the expression is AB*CD*E/+. Counting a PUSH for each of the 5 operands and a POP for each of the 4 operators (ignoring the pushes of intermediate results), the evaluation needs 5 PUSH and 4 POP instructions.