• retagged by
53,390 views
91 91 votes

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

  1. $6$ and $6$
  2. $8$ and $10$
  3. $9$ and $12$
  4. $4$ and $4$

6 Answers

Best answer
99 99 votes

A normal DAG construction will give $8$ nodes and $10$ edges as shown below.

Since, this question asks for minimum possible, we can assume algebraic simplification is allowed. So, $d = b + c, e = d - b$; can be simplified to $d = b + c$; $e = c$; Similarly, $e = d - b$; $a = e + b$; can be simplified to $a = d$. This gives the following DAG with $6$ nodes and $6$ edges.

Reference: https://cs.nyu.edu/~gottlieb/courses/2000s/2006-07-fall/compilers/lectures/lecture-14.html

Correct Answer: $A$

• edited by
47 47 votes

6,6 is the answer.

 

29 29 votes

Best approach of doing this question is "Go in reverse order". and it has asked for minimum so we can simplify wherever possible.

A = (E+B)

((D-B)+B) = (D) Because both + , - has same precedence

(B+C)

(B+(A+D))

(B+((B+C)+D))

 

3 3 votes

Simplifying the given equations : 
 
d = b + c (given) e = d – b (given) => d = b + c and e = c 
 
e = d - b (given) a = e + b (given) => a = d 
 
2014-set3-44 
 
Thus, the given DAG has 6 nodes and 6 edges. 

Answer:
Position:
Show:

Related questions

85 85 votes
8 answers 8 answers
32.2k
32.2k views
go_editor asked Sep 28, 2014
32,239 views
The minimum number of arithmetic operations required to evaluate the polynomial $P(X) = X^5+4X^3+6X+5$ for a given value of $X$, using only one temporary variable is ____...
33 33 votes
4 answers 4 answers
23.7k
23.7k views
Arjun asked Feb 18, 2021
23,651 views
Consider the following $C$ code segment:a = b + c; e = a + 1; d = b + c; f = d + 1; g = e + f;In a compiler, this code segment is represented internally as a directed acy...
9 9 votes
5 answers 5 answers
8.9k
8.9k views
go_editor asked Sep 28, 2014
8,939 views
In the context of modular software design, which one of the following combinations is desirable?High cohesion and high couplingHigh cohesion and low couplingLow cohesion ...