Question 4Asked in UGC NET Computer Science, December 2014 (Paper II & III, Selected Questions)

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)?

  1. A4 PUSH and 3 POP instructions
  2. B5 PUSH and 4 POP instructions
  3. C6 PUSH and 2 POP instructions
  4. D5 PUSH and 3 POP instructions
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.

From UGC NET Computer Science PYQ, December 2014 (Paper II & III, Selected Questions)

This is question 4 of UGC NET Computer Science PYQ, December 2014 (Paper II & III, Selected Questions). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.