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
- A$\mathrm{AB}^{*} \mathrm{CD}^{*}+$Correct answer
- B$\mathrm{A}^{*} \mathrm{BCD}^{*}+$
- C$\mathrm{AB}^{*} \mathrm{CD}+^{*}$
- 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.