Skip to content
Official PYQ · 2008

GATE CS 2008 Q53 — Regular and Context-free Languages

Explain with AI

Which of the following are regular sets?

  1. {anb2m∣n≥0,m≥0}\left\{a^nb^{2m} \mid n \geq 0, m \geq 0 \right\}

  2. {anbm∣n=2m}\left\{a^nb^m \mid n =2m \right\}

  3. {anbm∣n≠m}\left\{a^nb^m \mid n \neq m \right\}

  4. {xcy∣x,y,∈{a,b}∗}\left\{xcy \mid x, y, \in \left\{a, b\right\} ^* \right\}

Choose one option
View worked solution

Answer: A

To determine which of the given sets are regular, we analyze each language individually:

  1. L1={anb2m∣n≥0,m≥0}L_1 = \{a^n b^{2m} \mid n \geq 0, m \geq 0\}

    In this language, the number of aa's (nn) and the number of bb's (2m2m) are completely independent.

    • ana^n for n≥0n \geq 0 can be generated by the regular expression a∗a^*.
    • b2mb^{2m} for m≥0m \geq 0 represents an even number of bb's, which can be generated by (bb)∗(bb)^*.

    Since the two parts are independent, we can concatenate them to get the regular expression: a∗(bb)∗a^*(bb)^*. Thus, L1L_1 is regular.

  2. L2={anbm∣n=2m}L_2 = \{a^n b^m \mid n = 2m\}

    This language requires the number of aa's to be exactly twice the number of bb's. Since a finite automaton has finite memory, it cannot keep track of an arbitrary count to enforce this dependency. Thus, L2L_2 is not regular (it is deterministic context-free).

  3. L3={anbm∣n≠m}L_3 = \{a^n b^m \mid n \neq m\}

    This language requires comparing the count of aa's and bb's to ensure they are unequal. Since a finite automaton cannot perform arbitrary counting and comparison, L3L_3 is not regular (it is context-free).

  4. L4={xcy∣x,y∈{a,b}∗}L_4 = \{xcy \mid x, y \in \{a, b\}^*\}

    Here, xx and yy can be any arbitrary strings over the alphabet {a,b}\{a, b\}, separated by a single character cc. This can be directly represented by the regular expression: (a+b)∗c(a+b)∗(a+b)^* c (a+b)^* Since it can be described by a regular expression, L4L_4 is regular.

Therefore, only I and IV are regular sets.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Regular and Context-free Languages questions