1 1 vote Consider the following basic block:$$\begin{aligned}& w=x+y \\& z=w * 2 \\& x=y+z \\& w=x-y\end{aligned}$$The minimum number of NODES and the total number of OPERATOR LABELS required to represent the operations in the DAG of the above basic block, respectively, are:$7$ and $3$ $9$ and $7$ $6$ and $3$ $8$ and $4$ Compiler Design goclasses compiler goclasses-cs-dpp goclasses-cs-dpp-day-161 goclasses-compiler-practice-questions + – GO Classes 486 views answer comment Share Follow Print See 1 comment 1 1 comment reply isundeep0 commented Aug 31 reply Follow flag I am getting 7, 4 But since it is not one of the options, I optimized the above code. w = x - y w = y + z - y, (substituting, x = y + z) w = z Assigning doesn't need any new node. We can simply add the label x to the node z. And hence, (6, 3) 0 0 replyShare Please log in or register to add a comment.
0 0 votes Initial leaf nodes: $x, y, 2$ New nodes created: $w 0, z 0, x 0, w 1$ Total no of nodes $=7$ Total no of operator labels $=3$ A is correct GO Classes answered Dec 19, 2025 1 flag: ✌ Edit necessary (Prince_Garg “I think 6 and 3 is the perfect ans for this”) GO Classes comment Share Follow See all 3 Comments 3 3 Comments reply deadindope commented Dec 20, 2025 reply Follow flag I think the answer should be 6&2. Since the last expression can be reduced to just "w=z". so we don't need to solve the minus operation. 2 2 replyShare Shree2 commented Dec 20, 2025 reply Follow flag Expression will be w=(y+(x+y)*2)-y So, here distinct operator labels are +,* and -. So 7 and 3 will be right. 0 0 replyShare Me123 commented Jan 15 reply Follow flag Instead of multiping by 2 we add so we reduce one node and one operator so ANS. 6 AND 2 0 0 replyShare Please log in or register to add a comment.
0 0 votes A JAY_THAKAR answered Jan 11 JAY_THAKAR comment Share Follow 0 reply Please log in or register to add a comment.