retagged by
34,621 views
67 votes
67 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$
retagged by

4 Answers

Best answer
81 votes
81 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
15 votes
15 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 votes
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:

Related questions

60 votes
60 votes
7 answers
1
go_editor asked Sep 28, 2014
19,048 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 ____...
12 votes
12 votes
4 answers
2