GATE Computer ScienceHardGATE CS (PYQ pattern)

SDD: D → T L { L.inh = T.type }; T → int { T.type = integer }; L → L1 , id { L1.inh = L.inh; addType(id.entry, L.inh) }; L → id { addType(id.entry, L.inh) }. Its dependency graph for "int a , b , c" has a node for T.type, for each L.inh, for each id.entry and one dummy node for each addType call. How many nodes and edges does it have?

  1. A. 10 nodes, 9 edges
  2. B. 7 nodes, 6 edges
  3. C. 10 nodes, 7 edges
  4. D. 13 nodes, 12 edges

Correct answer: A. 10 nodes, 9 edges

Three ids give three L-nodes, three id.entry nodes and three addType dummies, plus T.type: 10 nodes. Edges: T.type → L.inh (top L), two L.inh → L1.inh edges down the left-recursive chain, and for each of the three addType calls one edge from its L.inh and one from its id.entry: 1 + 2 + 6 = 9.

More Compiler Design questions

Exams that ask this topic