GATE Computer ScienceVery hardGATE CSE · NIELIT
How many states does the canonical LR(0) collection of the augmented grammar S′ → S; S → a S b | a b have, and how many of them have a shift-reduce or reduce-reduce conflict (LR(0) conflicts)? Give the answer as (states, conflicting states).
- A. (6, 0)
- B. (6, 1)
- C. (7, 0)
- D. (5, 1)
Correct answer: A. (6, 0)
Building the item sets gives 6 states. No state mixes a completed item with another item, so the grammar is LR(0) and there are 0 conflicting states.
More Compiler Design questions
- For E → E + T | T; T → T F | F; F → ( E ) | id, how many LR(0) states have a conflict that is resolved by the SLR(1) FOLLOW-set check…
- How many distinct strings of length at most 6 (including the empty string) are generated by the grammar S → ( S ) | S S | ε?
- For the ambiguous grammar S → S S | a, how many distinct parse trees does the string aaaaaa (six a's) have?
- A DFA over {0, 1} has states 0–8 with start state 0 and accepting states {5, 6, 7, 8}. Transitions (on 0, on 1): 0:(1,2), 1:(3,4)…
- In a language with Algol-style call by name, int i = 1 and A = [10, 20, 30] (1-indexed) are global, and procedure P(p, q) { i = i + 1; p =…
- Indirect left recursion is removed from S → A a | b; A → A c | S d | ε by ordering the non-terminals S, A, substituting S into A's rules…