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
View worked solution
Answer: A
To find the minimum number of nodes and edges in the Directed Acyclic Graph (DAG) representation, we construct the DAG step-by-step while applying algebraic simplifications:
- Initial Leaves: We start with three leaf nodes for the initial values of the variables: , , and .
Total Nodes = 3, Edges = 0 a = b + c: Create Node 1 (operator+) with children and . Label this node as .
Total Nodes = 4, Edges = 2c = a + d: Create Node 2 (operator+) with children Node 1 () and . Label this node as .
Total Nodes = 5, Edges = 4d = b + c: Create Node 3 (operator+) with children and Node 2 (). Label this node as .
Total Nodes = 6, Edges = 6e = d - b: Since (from Node 3), substituting this gives . Thus, is algebraically equivalent to the value at Node 2. No new node is created; we simply add the label to Node 2.a = e + b: Since is equivalent to Node 2 (which represents ), we have . This is algebraically equivalent to Node 1. No new node is created; we simply move the label to Node 1.
Thus, the final DAG contains exactly 6 nodes (3 leaves and 3 interior operator nodes) and 6 edges.
Free practice · Your answers on this page are not saved.
