Home › GATE CSE › computerscience › Theory of Computation › Which language is REGULAR (recognised by some DF…
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)._
Related questions
Which class of grammars generates ALL recursively enumerable languages?What is a LEFTMOST DERIVATION?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$ isA LEFT-RECURSIVE rule in a CFG has the form $A \to A\alpha$ for some non-empty $\alpha$. WContext-free languages are CLOSED under which of the following operations?