GATE Computer ScienceVery hardGATE CSE
For S → C C; C → c C | d (augmented), the canonical LR(1) collection has some states that share an LR(0) core. By how many states does LALR(1) construction shrink the collection?
- A. 2
- B. 4
- C. 3
- D. 6
Correct answer: C. 3
Canonical LR(1) has 10 states; merging same-core states leaves 7, i.e. 3 fewer (the pairs {C→c.C, C→.cC, C→.d}, {C→d.} and {C→cC.} each appear in two lookahead variants).
More Compiler Design questions
- Grammar: S → A a | b A c | d c | b d a; A → d. How many conflicting (state, terminal) entries are there in its SLR(1) table, and how many…
- Consider the grammar S → a S | a S b S | ε. How many distinct parse trees does the string aaabb have?
- Procedure swap(x, y) { t = x; x = y; y = t; } is called as swap(i, a[i]) with i = 1 and a[1], a[2], a[3] = 2, 5, 9. Under call-by-name…
- A DFA reads binary strings most-significant bit first and accepts those whose numeric value is divisible by 12 (the empty string counts as…
- Let L = { w ∈ {a,b} : w contains the substring "aba" and |w| is even }. How many states does the minimal DFA for L have?
- A straight-line CFG B1→B2→B3→B4→B5 has: B1 defines x; B2 defines y; B3 uses y and defines z; B4 defines y; B5 uses x and z. Live-variable…