GATE Computer ScienceVery hardGATE CS (PYQ pattern)
L is the set of strings over {a, b} that contain abab as a substring but do not end with abab. How many states does the minimal complete DFA for L have?
- A. 8
- B. 9
- C. 10
- D. 5
Correct answer: B. 9
Before the first abab the DFA needs the KMP progress ε, a, ab, aba (4 states). After abab has occurred, it must still track the suffix progress towards abab to know whether the string currently ends with it: progress 0, a, ab, aba, abab, giving 5 more states (abab-ending is rejecting, the others accepting). No dead state is needed: 4 + 5 = 9.
More Compiler Design questions
- An LR parser for E → T E′; E′ → + T E′ | ε; T → F T′; T′ → F T′ | ε; F → ( E ) | id parses "id + id id". How many reductions does it make…
- For each choice of terminals x, y ∈ {a, b, c} consider G(x, y): S → A x B; A → a A | ε; B → b B | y. Of the nine grammars, how many are…
- The grammar S → a S | S a | b is ambiguous. How many distinct parse trees does the string "a a a b a a" have?
- For S → b A d | c A e | b B e; A → x; B → x (augmented), how many ACTION cells of the SLR(1) table are multiply defined, and how many…
- Procedures are nested as follows: main contains P (nesting depth 2); P contains Q (depth 3) and S (depth 3); Q contains R (depth 4)…
- Which of the following is/are true? I. An LL(1) grammar can contain ε-productions. II. An LL(1) grammar is never ambiguous. III. If FIRST…