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 the worked solutionReverse Polish form of \((A*B)+(C*D/E)\):\[A\ B\ *\ C\ D\ *\ E\ /\ +\]Each operand is pushed: A, B, C, D, E gives 5 PUSH.
Each of the 4 binary operators \(*,\ *,\ /,\ +\) pops its two operands and pushes the result back, a net removal of one item, so it is counted as one POP.\[\text{5 operands}\to5\ \text{PUSH},\qquad 4\ \text{operators}\to4\ \text{POP},\]leaving the single result on the stack.Answer: B
GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com