# Ullman (Compiler Design) Edition 2 Exercise 6.1 Question 1 (Page No. 362)

1 vote
223 views
Construct the DAG for the expression
$((x + y)-((x + y)\ast(x -y))) + ((x+y)\ast(x-y))$

1 vote

((x+y)−((x+y)∗(x−y))) and ((x+y)∗(x−y)) expression needed to be added together at the end. So according to me, DAG should be following...

DAG for the expression ((x+y)−((x+y)∗(x−y)))+((x+y)∗(x−y))

2
I think you missed this part "minus from the Top should be connected to multiply" because of this condition ((x+y)−((x+y)∗(x−y)))

## Related questions

1
208 views
Construct the DAG and identify the value numbers for the subexpressions of the following expressions, assuming $+$ associates from the left. $a+b+(a+b)$ $a+b+a+b$ $a+a+((a+a+a+(a+a+a+a))$
Assuming that function $widen$ in Fig. $6.26$ can handle any of the types in the hierarchy of Fig. $6.25(a)$, translate the expressions below. Assume that c and d are characters, $s$ and $t$ are short integers, $i$ and $j$ are integers, and $x$ is a float. $x=s+c$ $i=s+c$ $x=(s+c)\ast(t+d)$
Add to the translation of Fig. $6.19$ rules for the following productions: $E\rightarrow E_{1}\ast E_{2}$ $E\rightarrow + E_{1}\:$(unary plus)