Which language is REGULAR (recognised by some DFA)?
A$\{a^n b^n \mid n \geq 0\}$ (equal numbers of a's then b's)
B$\{w \in \{0,1\}^* \mid w \text{ contains an even number of 1's}\}$
C$\{a^p \mid p \text{ is prime}\}$
D$\{ww \mid w \in \{0,1\}^*\}$ (palindrome-like duplications)
Answer & Solution
Correct answer: B. $\{w \in \{0,1\}^* \mid w \text{ contains an even number of 1's}\}$
1. Regular languages are exactly those recognised by some DFA / NFA / regular expression.
2. Option B (even number of 1's): a 2-state DFA suffices. State 0 = even count of 1's so far (accepting), state 1 = odd. Reading 0 stays put; reading 1 toggles. Regular ✓.
3. Option A ($a^n b^n$): NOT regular. Any DFA has finite states, but to remember how many a's were read (to check the matching number of b's) requires unbounded memory. Pumping lemma confirms.
4. Option C (primes): NOT regular. Primes are not a regular set.
5. Option D (duplications $ww$): NOT regular. Needs unbounded memory to remember the first half.
6. Useful rule of thumb: if a language requires COUNTING or MATCHING unbounded structures, it's NOT regular.
_Source: Jeff Erickson, "Models of Computation", §2.5 + §2.10 (Regular vs non-regular examples)._
Keep practising Theory of Computation
Browse all Theory of Computation questions for GATE CSE, or explore more Computer Science topics.
Related questions
Which class of grammars generates ALL recursively enumerable languages?Which of the following languages is CONTEXT-FREE?Consider the grammar $S \to (S) \mid SS \mid \varepsilon$. The language generated isEvery regular language is also context-free. The PROOF construction isThe CYK algorithm parses a CFG in CNF. Its time complexity for a string of length $n$ isContext-free languages are RECOGNISED by which type of machine?A CFG is AMBIGUOUS ifConsider the CFG with rule $S \to aSb \mid \varepsilon$. The language generated is