GATE Computer ScienceVery hardGATE CSE
How many strings of length 10 over {a, b} belong to the language of (a+b)*(aab + bba)(a+b)*, that is, contain aab or bba as a substring?
- A. 20
- B. 1040
- C. 1004
- D. 956
Correct answer: C. 1004
Counting the strings that avoid both aab and bba (there are 20 of them, via a small suffix-tracking automaton or direct enumeration) leaves 1024 − 20 = 1004 that contain one of them.
More Theory of Computation questions
- Let L = { w ∈ {a, b} : (|w|a + 2·|w|b) mod 12 ∈ {1, 5, 9} }, where |w|a and |w|b count the a's and b's. What is the number of equivalence…
- Consider these problems: (a) Given a DFA M, is L(M) empty? (b) Given two CFGs G₁, G₂, is L(G₁) ∩ L(G₂) = ∅? (c) Given a TM M and input w…
- How many of the following statements are true? (i) DCFLs are closed under complement. (ii) CFLs are closed under intersection with a…
- Among the six languages L₁ = {aⁱbʲcᵏdˡ : i = k and j = l}, L₂ = {aⁱbʲcᵏ : i = j or j = k}, L₃ = {wwᴿ : w ∈ {a,b}}, L₄ = complement of…
- A DFA reads a binary string least-significant bit first (so the first symbol read is the 2⁰ bit) and must accept exactly the strings whose…
- How many strings of length at most 6 (the empty string included) over {a, b} belong to L(aba)?