GATE Computer ScienceHardGATE CS
Which regular expression over {0,1} denotes exactly the set of strings that do not contain two consecutive 1s?
- A. (0 + 10)*1*
- B. (0*1)*0*
- C. (0 + 01)*(ε + 1)
- D. (0 + 10)*(ε + 1)
Correct answer: D. (0 + 10)*(ε + 1)
Every 1 except a possible final one must be followed by a 0, so the string is a sequence of blocks 0 or 10, optionally ending with a lone 1. The option with 1* wrongly allows 11, (0*1)*0* allows 11, and (0 + 01)* misses strings like 10.
More Theory of Computation questions
- Which of the following problems are decidable? I. Is L(G) empty for a given CFG G? II. Is L(G1) ∩ L(G2) empty for given CFGs G1 and G2?…
- Let L = { w ∈ {a, b} : (number of a's − number of b's) is divisible by 4 }. How many states does the minimal DFA for L have?
- A grammar G in Chomsky Normal Form (no ε-production) generates a string w of length 9. How many derivation steps does any derivation of w…
- Let L = { w ∈ {a, b} : w contains at most 3 a's and at least 2 b's }. How many states does the minimal complete DFA for L have?
- Let #ab(w) and #ba(w) be the numbers of occurrences of the substrings ab and ba in w ∈ {a, b}. Which one of the following languages is…
- Let L = { w ∈ {a, b} : w begins with aba, or (w ends with b and na(w) ≡ 0 (mod 3)) }. The minimal complete DFAs for L and for its reversal…