Skip to content

ISRO Scientist/Engineer CSE 2023Data Structures › Stacks and Expression Evaluation

ISRO Scientist/Engineer CSE 2023 PYQ: In Reverse Polish notation, expression $\mathrm{A} ^{*} \mathrm{~B}+\mathrm{C}^{*} \mathrm{D}$ is written as

In Reverse Polish notation, expression $\mathrm{A} ^{*} \mathrm{~B}+\mathrm{C}^{*} \mathrm{D}$ is written as

  1. A
    $\mathrm{AB}^{*} \mathrm{CD}^{*}+$
    Correct answer
  2. B
    $\mathrm{A}^{*} \mathrm{BCD}^{*}+$
  3. C
    $\mathrm{AB}^{*} \mathrm{CD}+^{*}$
  4. D
    $\mathrm{A}^{*} \mathrm{~B}^{*} \mathrm{CD}+$

Answer

(A) $\mathrm{AB}^{*} \mathrm{CD}^{*}+$

Approach

Reverse Polish (postfix) notation places each operator immediately after its two operands. The infix expression A * B + C * D has two multiplications that bind tighter than the addition, so it parses as (A * B) + (C * D). Convert each sub-expression to postfix and then append the top-level operator.

Reviewed by ISRO IQ Editorial Team.