GATE Computer ScienceHardGATE CS (PYQ pattern)
How many strings of length 20 over {a, b} do not contain aaa as a substring?
- A. 917504
- B. 223317
- C. 13530
- D. 224317
Correct answer: B. 223317
Classify by the trailing block of 0, 1 or 2 a's: t(n) = t(n−1) + t(n−2) + t(n−3) (tribonacci-type recurrence with t(0) = 1, t(1) = 2, t(2) = 4). For n = 20 this is 223317.
More Theory of Computation questions
- How many binary strings of length exactly 16 (leading zeros allowed) represent a number divisible by 5?
- How many binary strings of length 12 contain no two consecutive 1s and, read as a binary number (leading zeros allowed), are divisible by 3?
- How many binary strings of length 12 have the number of occurrences of 01 equal to the number of occurrences of 10?
- How many strings of length 10 over {a, b, c} contain neither ab nor ba as a substring?
- 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…