Back to the 2024 paper

Module 1: Introduction & Regular Languages

20242m

Which of the following is a regular language?

(i) Strings whose length is a sequence of prime numbers
(ii) Palindrome strings
(iii) Strings containing substring wwrww^r
(iv) Strings with even number of 00’s

Worked SolutionAI Assisted

Answer

Correct Option: (iv) Strings with even number of 00’s

Explanation

(iv) Even number of 00’s — Regular

Language L4={w∈{0,1}∗∣#0(w) is even}L_4 = \{ w \in \{0,1\}^* \mid \#_0(w) \text{ is even} \} is regular. DFA with 2 states suffices:

  • q0q_0: even count (start, accepting)
  • q1q_1: odd count
    δ(q0,0)=q1,  δ(q1,0)=q0,  δ(q,1)=q\delta(q_0,0)=q_1,\;\delta(q_1,0)=q_0,\;\delta(q,1)=q.

Regular expression: (1∗0 1∗0)∗1∗(1^*0\,1^*0)^*1^* or (1∗01∗01∗)∗(1^*01^*01^*)^*.

By Myhill-Nerode, only 2 equivalence classes.

(i) Length is prime — Not regular

L1={w∣∣w∣∈PRIMES}L_1 = \{ w \mid |w| \in \text{PRIMES} \}. Use Pumping Lemma. Let pp be pumping length, choose w=0pw = 0^p where pp prime, pump gives length p+k∣y∣p + k|y| which will be composite for suitable kk (e.g., k=pk=p). So not regular. Primes set not ultimately periodic.

(ii) Palindromes — Not regular

L2={wwr∣w∈Σ∗}?L_2 = \{ ww^r \mid w\in\Sigma^*\}^{? } Classic non-regular. Requires unbounded stack to compare second half with first reversed. Pumping lemma: w=0p1 0pw = 0^p1\,0^p in palindrome form fails. Needs PDA, is CFL but not regular.

(iii) Contains wwrww^r as substring — also Not regular

L3={x wwr y∣… }L_3 = \{ x \, ww^r \, y \mid \dots\} Need to remember arbitrarily long ww to check wrw^r follows. This is not regular (can be shown via Myhill-Nerode with infinitely many distinct suffixes). It is context-sensitive.

Final Answer

Only (iv) is regular.

Similar questions

Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.