Question 60

The following postfix expression with single-digit operands is evaluated using a stack:

The following postfix expression with single-digit operands is evaluated using a stack: 823^/23*+51*- (Note that ^ is the exponentiation operator.) The top two elements of the stack after the first * is evaluated, are
  1. A6, 1
  2. B5, 7
  3. C3, 2
  4. D1, 5
Show answerHide answer

Correct answer: (A) 6, 1

Explanation

8 2 3 ^ gives 2³ = 8, then 8 / 8 = 1. Next 2 and 3 are pushed and * gives 6. The stack now holds 1, 6, so the top two elements are 6 and 1.

From DSSSB TGT Computer Science Practice Set 2

This is question 60 of DSSSB TGT Computer Science Practice Set 2. 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.