Consider the basic block given below. a = b + c c = a + d d = b + c e = d - b a = e + b The minimum number of nodes and edges present in the DAG representation of the above basic block respectively are
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2014 Set 3 · Q34
Time
a = b + c
c = a + d
d = b + c
e = d - b
a = e + bThe minimum number of nodes and edges present in the DAG representation of the above basic block respectively areSelect one answerSingle correct
Solution
Official answer: A) 6 and 6
Local OptimisationLet us construct the Directed Acyclic Graph (DAG) for the basic block:
a = b + c
Leaf nodes: ,
Node , labeled (2 edges)
c = a + d
Leaf node:
Node , labeled (2 edges)
d = b + c
Node , labeled (2 edges)
e = d - b
Since , the expression .
Thus, evaluates to the value represented by node , so label is attached to .
a = e + b
Since is , , which is already computed at node .
Thus, the new value of is attached to node .
Total Nodes:
3 leaf nodes:
3 interior operation nodes:
Total nodes =
Total Edges:
(2 edges)
(2 edges)
(2 edges)
Total edges =
Therefore, the minimum number of nodes and edges is 6 and 6, which corresponds to option (A).
Try the question first, then check your work.
Examiner trap
Check whether subsequent operations ( and ) reuse existing subexpression nodes when algebraically simplified or when looking at existing computations.
This Local Optimisation previous year question is Q34 of the GATE CSE 2014 Set 3 paper. Find more GATE CSE PYQs on Local Optimisation in Compiler Design, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 4 related Local Optimisation PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Local Optimisation has 4 GATE CSE PYQs across 4 papers from 2013 to 2025. 3 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2014 Set 3.
How GATE tests Local OptimisationIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.