GATE Computer ScienceHardGATE CS (PYQ pattern)
Which regular expression denotes exactly the set of strings over {a, b} with an EVEN number of a's (zero included)?
- A. (b*ab*ab*)*
- B. b*(ab*a)*b*
- C. (aa + bb + ab + ba)*
- D. (b + ab*a)*
Correct answer: D. (b + ab*a)*
(b + ab*a)*: each factor has 0 or 2 a's, and any even-a string splits into b's and a…a pairs: correct. (b*ab*ab*)* misses b (zero a's but non-empty). b*(ab*a)*b* allows b's only outside the a…a pairs, so it misses aabaa (4 a's: aa, b, aa). (aa + bb + ab + ba)* is even LENGTH, e.g. it contains ab.
More Theory of Computation questions
- A DFA has 8 states. To decide whether the language it accepts is infinite, it suffices to check whether it accepts some string whose…
- Which of the following statements are correct? I. The reversal of a deterministic context-free language is always deterministic…
- Which of the following statements are correct? I. Recursively enumerable languages are closed under union and intersection. II…
- L₁ and L₂ are context-free languages. Which statement about L₁ ∩ L₂ is always correct?
- The grammar S → aSb | SS | ab generates 14 strings of length 8. How many of these strings have MORE than one parse tree?
- How many strings of length 6 over {a, b} match the regular expression (a + ab)(b + ba)?