GATE Computer ScienceHardGATE CS (PYQ pattern)
Let L = { w ∈ {a, b}* : (2·n_a(w) + 4·n_b(w)) mod 6 = 2 }. How many strings of length exactly 7 belong to L?
- A. 42
- B. 43
- C. 21
- D. 64
Correct answer: B. 43
2n_a + 4n_b ≡ 2 (mod 6) ⇔ n_a + 2n_b ≡ 1 (mod 3). With n_b = 7 − n_a this is n_a + 14 − 2n_a ≡ 1, i.e. n_a ≡ 13 ≡ 1 (mod 3), so n_a ∈ {1, 4, 7}: C(7,1) + C(7,4) + C(7,7) = 7 + 35 + 1 = 43. (Solving with n_a ≡ 2 gives the trap 42.)
More Theory of Computation questions
- A DFA reads ternary numerals over {0, 1, 2}, most significant digit first (leading zeros allowed; ε has value 0 and is accepted), and…
- Binary strings are read LSB first (the leftmost symbol is the least significant bit; ε has value 0 and is accepted). How many states does…
- Binary strings are read LSB first (the leftmost symbol is the least significant bit; ε has value 0 and is accepted). The minimal DFA for…
- A DFA over {0, 1} reads a binary numeral MSB first (leading zeros allowed, ε has value 0) and accepts iff the value ≡ 3 (mod 8). How many…
- L = { w ∈ {a, b} : (na(w) − nb(w)) ≡ 0 (mod 3) and |w| is even }. How many states does the minimal complete DFA for L have?
- Let L = { w ∈ {a, b} : |w| ≥ 3 and the 3rd symbol from the right end equals the last symbol }. How many states does the minimal complete…