GATE Computer ScienceVery hardGATE CS (PYQ pattern)
How many strings of length 9 over {a, b} satisfy (n_a − n_b) ≡ 0 (mod 3) AND contain no bb as a substring?
- A. 170
- B. 36
- C. 89
- D. 30
Correct answer: B. 36
With n_a + n_b = 9, n_a − n_b = 9 − 2n_b ≡ 0 (mod 3) ⇔ n_b ≡ 0 (mod 3). No bb means the b's are separated: choose n_b of the 10 gaps around the n_a a's, C(n_a + 1, n_b). n_b = 0: C(10,0) = 1; n_b = 3: C(7,3) = 35; n_b = 6: C(4,6) = 0. Total 36 (170 ignores bb, 89 ignores the mod condition).
More Theory of Computation questions
- How many binary strings of length 10 contain 0110 as a substring?
- How many strings of length 7 over {a, b} belong to the language of the regular expression (a + ab + ba)?
- How many strings of length 10 over {a, b} lie in the language of the regular expression abab?
- The regular expression ((aa + bb)(ab + ba)) is over Σ = {a, b}. How many states does the minimal complete DFA for its language have?
- Exactly one of the following strings is NOT in the language of (a + ab)(b + ba). Which one?
- The regular expression a(bab)a is over Σ = {a, b}. How many states does the minimal complete DFA for its language have?