GATE Computer ScienceVery hardGATE CS (PYQ pattern)
How many strings of length 10 over {a, b} have an even number of occurrences of ab AND an even number of occurrences of ba?
- A. 272
- B. 256
- C. 512
- D. 136
Correct answer: A. 272
Let r be the number of runs. If the first and last symbols differ, #ab and #ba differ by 1, so one is odd. If they agree, r is odd and #ab = #ba = (r − 1)/2, which must be even: r ≡ 1 (mod 4). Strings of length 10 with r runs: 2·C(9, r − 1). r ∈ {1, 5, 9}: 2(1 + 126 + 9) = 272.
More Theory of Computation questions
- How many strings of length 8 over {a, b} begin with b and contain no aa as a substring?
- Over Σ = {a, b, c}, how many strings of length 6 have an even number of a's and do not contain cc?
- Let L = { aⁿ : n = 1, or n ≥ 3 and (n ≡ 2 (mod 4) or n ≡ 3 (mod 6)) }. How many states does the minimal DFA for this unary language have?
- Let L = { aⁿ : n² ≡ 1 (mod 8) }. How many states does the minimal DFA for L have?
- Let L = { aⁿ : n ≥ 5 and n ≡ 1 (mod 3) }. How many states does the minimal DFA for the concatenation L·L have?
- Let L = { w ∈ {a, b} : |w| ≥ 5 and the 5th symbol from the LEFT equals the 1st symbol }. How many states does the minimal complete DFA for…