GATE Computer ScienceVery hardGATE CS (PYQ pattern)
How many strings of length 10 over {a, b, c} contain neither ab nor ba as a substring?
- A. 8119
- B. 57001
- C. 8631
- D. 5120
Correct answer: A. 8119
Count with a 3-state machine (last symbol a, b or c). Transitions: a→{a, c}, b→{b, c}, c→{a, b, c}; summing the path counts for 10 steps gives 8119.
More Theory of Computation questions
- Taking Brzozowski quotients: let L = L(r) with r = a(bab) over {a, b}. A regular expression for the set of strings w such that bw ∈ L is
- Grammar G: S → ASB | ε; A → aAS | a; B → SbS | A | bb. After eliminating all ε-productions in the standard way (every way of deleting…
- Grammar G: S → AB | ASB | ε; A → a | aA | aAS; B → A | Sb | SbS | b | bS | bb. After eliminating the unit production(s) B → A (copy A's…
- In the grammar S → AB | aC | b; A → a | aE; B → bB | bD; C → c | cC; D → dD; E → e (start S), how many variables are useless (not…
- In the grammar S → AB | CD; A → aA | BC; B → b | CC; C → AC | c | ε; D → d | DA; E → eE | ε (start S), how many variables are nullable…
- A CNF grammar has productions S → AB | BC; A → BA | a; B → CC | b; C → AB | a. The CYK algorithm is run on the string baaba, filling a…