1 1 vote Consider the expression tree shown below. Each leaf represents a numerical value, which can be chosen from the set $\{-1,1\}$. Over all possible choices of the values at the leaves, what is the MAXIMUM possible value of the expressiog represented by the tree? Compiler Design goclasses compiler goclasses-cs-dpp goclasses-cs-dpp-day-183 goclasses-compiler-practice-questions numerical-answers + – GO Classes 233 views answer comment Share Follow Print See 1 comment 1 1 comment reply Aman Shukla commented Mar 28 reply Follow flag 4 0 0 replyShare Please log in or register to add a comment.
0 0 votes THE LEAVES (LEVEL 3) Each leaf can be either $-1$ or $1$. LEVEL 2 NODES (FROM LEFT TO RIGHT)MULTIPLICATION NODE ($\times$): Possible values are $1 \times 1=1,(-1) \times(-1)=1$, or $1 \times (-1)=-1$. Range: $\{-1,1\}$ DIVISION NODE ($÷$): Possible values are $1 / 1-1,(-1) /(-1)-1,1 /(-1)-1$, or $(-1) / 1--1$. Range: $\{-1,1\}$ SUBTRACTION NODE ($-$): Possible values are $1-1=0,(-1)-(-1)=0,1$ -$(-1)=2$, or $(-1)-1=-2$. Range: $\{-2,0,2\}$ MULTIPLICATION NODE ($\times$): Same logic as the first node. Range: $\{-1,1\}$ LEVEL 1 NODESLEFT ADDITION NODE ($+$): Combines the first × node $\{-1,1\}$ and the ÷ node $\{-1,1\}$. Maximum: $1+1=2$. Minimum: $-1+(-1)=-2$. Range: $\{-2,0,2\}$ RIGHT MULTIPLICATION NODE ($\times$): Combines the - node $\{-2,0,2\}$ and the $x$ node $\{-1,1\}$. Maximum: $2 \times 1=2$ or $-2 \times-1=2$. Range: $\{-2,0,2\}$ THE ROOT NODE ($\times$) The root multiplies the results of the two Level 1 nodes. Both subtrees have a maximum possible value of $2$ and a minimum of $-2$. To maximize the product: $2 \times 2=4$ or $(-2) \times(-2)=4$. GO Classes answered Jan 23 GO Classes comment Share Follow 0 reply Please log in or register to add a comment.