Build the DAG: identical sub-expressions share one node.
Leaves (operands): $b$, $c$ and the constant $1$ (3 nodes).
Internal nodes: 1. $b+c$ — computed once and **shared** by `a = b+c` and `d = b+c`. 2. $(b+c)+1$ — shared by `e = a+1` and `f = d+1` (since $a$ and $d$ are the same node). 3. $e+f$ — node for `g`, whose two children are the same node, so it is a node with both edges going to the shared node.
Total nodes $=3+3=\mathbf6$.
More Code Optimization and Data Flow Analysis questions
GATE 2015 CS (CS1) Q46– A variable x is said to be live at a statement S i in a program if the following three…
GATE 2017 CS (CS1) Q53– Consider the following grammar: where `relop` is a relational operator (e.g., <, >, ...),…