GATE Computer ScienceModerateGATE CSE
A grammar in Chomsky normal form (no ε-productions) is used to derive a string of length 9. How many derivation steps (production applications) are needed?
- A. 17
- B. 9
- C. 16
- D. 18
Correct answer: A. 17
A string of length n needs n − 1 binary-rule steps and n terminal-rule steps: 8 + 9 = 17.
More Theory of Computation questions
- Over {a, b}, L = { w : |w| ≥ 3 and the third symbol from the right end is a }. What is the number of states in its minimal complete DFA?
- Over {a, b}, let L = { w : na(w) ≡ 1 (mod 4) OR nb(w) is even }. What is the number of states in its minimal complete DFA?
- Over {a, b}, L = { w : the fourth symbol from the right end of w is a }. How many states does the minimal complete DFA of L have?
- How many strings of length 8 over {a, b} contain aa as a substring but do not contain bb as a substring?
- An NFA with ε-moves over {a, b} has states 0–4, start 0 and accepting state 4. Transitions: 0 –ε→ 1, 2 –ε→ 3; δ(0,a) = {0}; δ(1,b) = {2}…
- The grammar S → SS | a | b is ambiguous. How many distinct parse trees does it give for the string ababa?