retagged by
2,555 views
2 votes
2 votes
In questions like, when asked to find the edges or nodes in the DAG of following expression,

a=a+b*c-(a+b)+(b*c)

do we also consider "=" as a node and its related edges?
retagged by

4 Answers

2 votes
2 votes

No, usually we don't consider "=" during DAG drawing, but in options if "=" is given then yes we have to consider it. Then no of nodes and edges also increase accordingly. 

 

DAG of the following expression: (by creating 3 Address code) 

 

 

And We can draw the DAG without creating 3-Address Code also: 

 

 

So in both the cases we are getting  ​​​​​​8 Nodes 10 Edges.

1 votes
1 votes

No,you should not conisder "=" while finding minimum nodes,but if in options you should not find any option without "=",then you may try using "=".

Please refer 

https://gateoverflow.in/2068/gate2014-3_34?show=2068#q2068

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

0 votes
0 votes
No we dont consider the equal sign , The answer for it will be , Number of Nodes = 8 , number of edges = 10.

Related questions

0 votes
0 votes
2 answers
1
saumya mishra asked Jun 13, 2018
9,382 views
Question.Construct the Dag for the following Assume that + is left associative?a)a+b+(a+b)b)a+b+a+bc)a+a+(a+a+a+(a+a+a+a))Please give the Answer to these questions?????
1 votes
1 votes
1 answer
2
neha singh asked Mar 17, 2017
2,041 views
A directed acyclic graph represents one form of intermediate representation.The number of non-terminal nodes in DAG of a=(b+c)*(b+c)a)2b)3c)4d)5