# UGC-NET | UGC NET CS 2014 Dec – II | Question 8

• Last Updated : 10 Sep, 2021

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)?
(A) 4 PUSH and 3 POP instructions
(B) 5 PUSH and 4 POP instructions
(C) 6 PUSH and 2 POP instructions
(D) 5 PUSH and 3 POP instructions

Explanation: Reverse polish notation is a system of formula notation without brackets or special punctuation.
To evaluate (A ∗ B) + (C ∗ D / E):
First avoid brackets and punctuation and convert it into postfix form i.e. AB+CDE/*+
Now push AB
On * pop AB and perform A * B. Now push back the result(say it X).
Push CDE.
On / pop DE and push back the result(say it Y).
On * Pop CY and perform * operation and push the result(say it z).
On + pop XZ and perform + operation and and push back the final answer.
Above computation include 5 PUSH and 4 POP instructions.
So, option (B) is correct.

Quiz of this Question

My Personal Notes arrow_drop_up