• retagged by
3,856 views
2 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?

4 Answers

2 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 1 vote

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 0 votes
No we dont consider the equal sign , The answer for it will be , Number of Nodes = 8 , number of edges = 10.
Position:
Show:

Related questions

0 0 votes
2 2 answers
13.8k
13.8k views
saumya mishra asked Jun 13, 2018
13,763 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 1 vote
1 answers 1 answer
3.0k
3.0k views
neha singh asked Mar 17, 2017
2,961 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