GATE Computer ScienceHardGATE CSE · UGC NET
Left factoring is applied to A → a b c | a b d | a e | f, and the shared prefixes are factored as far as possible, with new non-terminals A′ and A″. How many productions does the resulting grammar have?
- A. 5
- B. 6
- C. 7
- D. 4
Correct answer: B. 6
A → a A′ | f; A′ → b A″ | e; A″ → c | d: 2 + 2 + 2 = 6 productions.
More Compiler Design questions
- How many cells of the LL(1) parsing table of E → T E′; E′ → + T E′ | ε; T → F T′; T′ → F T′ | ε; F → ( E ) | id contain a production?…
- 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…
- 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)…