Question

Which of the following languages is/are regular?

L1={wxwR∣w,x∈{a,b}+ and ∣w∣,∣x∣>0}L_1 = \{w x w^R \mid w, x \in \{a, b\}^+ \text{ and } |w|, |x| > 0\}, wRw^R is the reverse of string ww
L2={ambn∣m≠n and m,n>0}L_2 = \{a^m b^n \mid m \neq n \text{ and } m, n > 0\}
L3={apbqcr∣p,q,r≥0}L_3 = \{a^p b^q c^r \mid p, q, r \ge 0\}

Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2015 answer key

Solution

Analyze each language using closure properties and finite-state expressibility.

  1. Analyze L1={wxwR∣w,x∈{a,b}+ and ∣w∣,∣x∣>0}L_1 = \{w x w^R \mid w, x \in \{a, b\}^+ \text{ and } |w|, |x| > 0\}:
    Since ∣w∣≥1|w| \ge 1, we can choose ww to be a single symbol (aa or bb).
  • If w=aw = a, then wR=aw^R = a, producing strings of the form axaa x a where x∈{a,b}+x \in \{a, b\}^+.
  • If w=bw = b, then wR=bw^R = b, producing strings of the form bxbb x b where x∈{a,b}+x \in \{a, b\}^+.
    Conversely, any string in {a,b}+\{a, b\}^+ that starts and ends with the same symbol and has length ≥3\ge 3 can be written as wxwRw x w^R by setting ww to the first symbol (so ∣w∣=1|w| = 1).
    Thus, L1L_1 is simply the regular language:
L1=a(a+b)+a∪b(a+b)+b.L_1 = a(a + b)^+ a \cup b(a + b)^+ b.

Since it is expressed by a regular expression, L1L_1 is regular.

  1. Analyze L2={ambn∣m≠n and m,n>0}L_2 = \{a^m b^n \mid m \neq n \text{ and } m, n > 0\}:
    Recognizing whether m≠nm \neq n requires infinite memory to compare the count of aa's and bb's. By the Pumping Lemma, L2L_2 is not regular.
  1. Analyze L3={apbqcr∣p,q,r≥0}L_3 = \{a^p b^q c^r \mid p, q, r \ge 0\}:
    This language is generated directly by the regular expression a∗b∗c∗a^* b^* c^*, so L3L_3 is regular.

Thus, L1L_1 and L3L_3 only are regular (option A).

Final answer

A

Common trap

Assuming L1L_1 is non-regular like palindromes, overlooking that x∈{a,b}+x \in \{a, b\}^+ allows absorbing all intermediate characters while keeping ∣w∣=1|w| = 1.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2015 Computer Science and Information Technology (CS) Session 2
Question
61 of 65, printed as CS Q.51
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.