299 views
0 0 votes

Given the Prefix (Polish Notation) expression:

$$
+* / \mathbf{A} \mathbf{B} \mathbf{C}-\mathbf{D} \mathbf{E}
$$


And the following operand values: $A=12, B=4, C=2, D=10$, $E=5$.

Assuming standard integer arithmetic for all operators, what is the final value represented by the expression tree?

  1. $29$
     
  2. $6$
     
  3. $1$
     
  4. $11$

4 Answers

0 0 votes
The Prefix expression corresponds to the Infix expression

$(((A / B) \times C)+(D-E))$.

Evaluating this as $((12 / 4) \times 2)+ (10-5)$ yields $(3 \times 2)+5=11$.
0 0 votes
for prefix expression to postfis , we will use bottom up parsers

we means  RMD,
 +∗/ABC−DE

step1:+∗/ABC−D5

step 2:+∗/ABC−105

step 3:+∗/ABC(10-5)

step 4:+∗/AB2(10-5)

step 5:+∗/A42(10-5)

step 6:+∗/1242(10-5)

step 7:+∗(12/4)2(10-5)

step 8:+((12/4)*2)(10-5)

step 9:((12/4)*2)+(10-5)
we evaluate it : 6+5=11
option D
Answer:
Position:
Show:

Related questions

4 4 votes
3 3 answers
372
372 views
GO Classes asked Dec 23, 2025
372 views
Consider the tree shown below.Each leaf represents a numerical value, which can be chosen to be either $\mathbf{0}$ or $\mathbf{2}$.Over all possible choices of the value...
1 1 vote
2 2 answers
302
302 views
GO Classes asked Dec 23, 2025
302 views
A programmer writes the following invalid C statement: $\verb|int total_val#ue =10;|$ .Assuming the compiler adheres to a standard compilation model, which component is p...
1 1 vote
2 2 answers
294
294 views
GO Classes asked Dec 23, 2025
294 views
Consider the following ANSI C code segment: w = 5 - y->f_one - x - 2; for (j = 1; j < 150; j = j + 3) { if (j < w) { a = a + y->f_two; b = b + 5 -...
3 3 votes
3 3 answers
317
317 views
GO Classes asked Dec 23, 2025
317 views
Consider line number $\textbf{4}$ of the following C-program. int main() { /* Line 1 */ int value, result; /* Line 2 */ value = 100; /* Line 3 */ result = val...