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?
- A. 10 nodes, 9 edges
- B. 7 nodes, 6 edges
- C. 10 nodes, 7 edges
- 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
- Which of the following are true? I. Every LL(1) grammar is LR(1). II. Every LL(1) grammar is LALR(1). III. Every LALR(1) grammar is LR(1)…
- Available-expressions analysis (expressions compared textually, so a b and b a differ; assigning an operand kills an expression) is run on…
- Nested procedures: main (depth 1) contains A (depth 2); A contains B (depth 3); B contains C (depth 4). C also calls itself recursively…
- void p(int x, int y) { x = x + 1; y = y + x; } is called as p(a, a) with a = 2. What is a after the call when the parameters are passed by…
- How many distinct LR(0) items does the grammar E → T E'; E' → + T E' | ε; T → F T'; T' → F T' | ε; F → ( E ) | id have (do not augment it…
- Dead-code elimination deletes every assignment whose target is not live immediately after it (live-variable analysis), and is repeated…