GATE Computer ScienceVery hardGATE CS (PYQ pattern)
L1 is the set of strings over {a, b} whose third symbol from the right is a; its minimal DFA has 8 states. L2 = L1 ∩ {strings of even length}. How many states does the minimal complete DFA for L2 have?
- A. 16
- B. 8
- C. 12
- D. 6
Correct answer: D. 6
The product construction gives 16 states, but most of the window is wasted. For an even-length prefix w, any continuation must also have even length: a continuation of length 2 needs the last symbol of w to be a, and the empty continuation needs w's third-from-last symbol; for an odd-length prefix only its last two symbols matter, and only its second-last for a 1-symbol continuation. Distinguishing what really matters leaves 6 Myhill–Nerode classes (checked by enumerating all prefixes and suffixes up to length 10).
More Compiler Design questions
- For the augmented grammar S′ → S; S → ( L ) | x; L → S | L , S, how many states does the canonical LR(1) automaton have, and in how many…
- G: S → T | S ; T; T → a | ( S ). Removing the left recursion gives G′: S → T R; R → ; T R | ε; T → a | ( S ). Which statements are true?…
- The grammar A → B a | A a | c; B → B b | A b | d is transformed by the standard algorithm that removes (indirect and immediate) left…
- 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 {…
- 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…