Question

Let L1={w∈{0,1}∗∣w has at least as many occurrences of (110)’s as (011)’s}L_1 = \{w \in \{0, 1\}^* \mid w \text{ has at least as many occurrences of } (110)\text{'s as } (011)\text{'s}\}. Let L2={w∈{0,1}∗∣w has at least as many occurrences of (000)’s as (111)’s}L_2 = \{w \in \{0, 1\}^* \mid w \text{ has at least as many occurrences of } (000)\text{'s as } (111)\text{'s}\}. Which one of the following is TRUE?

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

Solution

Evaluate substring transition counting bounds to determine regularity of each language.

  1. Analysis of L1L_1:

    • Consider the patterns 110110 and 011011.
    • A 110110 pattern occurs when a sequence of at least two 1s transitions into a 0 (i.e., ...110...).
    • A 011011 pattern occurs when a 0 transitions into at least two 1s (i.e., ...011...).
    • In any binary string, to have another 110110, the string must transition back through 011011 to enter a block of 1s again.
    • Consequently, occurrences of 110110 and 011011 strictly alternate along the string, meaning that for any prefix ww:
      ∣#110(w)−#011(w)∣≤1.|\#_{110}(w) - \#_{011}(w)| \le 1.
    • Because the difference between the two counts is strictly bounded by 1, a finite automaton with a small number of states can keep track of the difference.
    • Therefore, L1L_1 is regular.
  2. Analysis of L2L_2:

    • Consider strings in the regular subset 0∗1∗0^* 1^*, specifically strings of the form w=0n+21m+2w = 0^{n+2} 1^{m+2} for n,m≥0n, m \ge 0.
    • In 0n+20^{n+2}, the substring 000000 occurs exactly nn times.
    • In 1m+21^{m+2}, the substring 111111 occurs exactly mm times.
    • There are no overlapping 000000 or 111111 cross-patterns between 0 and 1.
    • For w∈L2w \in L_2, we must have n≥mn \ge m. The language L2∩0∗1∗={0n+21m+2∣n≥m}L_2 \cap 0^* 1^* = \{0^{n+2} 1^{m+2} \mid n \ge m\} is a well-known non-regular context-free language.
    • Since intersection with a regular language yields a non-regular language, L2L_2 CANNOT be regular.
  3. Conclusion:
    L1L_1 is regular but not L2L_2, matching option (A).

Final answer

A

Common trap

Assuming that any language counting occurrences of two different substrings must be non-regular; when occurrences strictly alternate, the difference remains bounded and the language is regular.

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

Source

Paper
GATE 2014 Computer Science and Information Technology (CS) Session 2
Question
46 of 65, printed as CS Q.36
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.