Skip to content
Official PYQ · 2012

GATE CS 2012 Q25 — Regular and Context-free Languages

Explain with AI

Given the language L={ab,aa,baa}L = \left\{ab, aa, baa\right\}, which of the following strings are in L∗L^{*}?

  1. abaabaaabaaabaabaaabaa
  2. aaaabaaaaaaaabaaaa
  3. baaaaabaaaabbaaaaabaaaab
  4. baaaaabaabaaaaabaa
Choose one option
View worked solution

Answer: C

To determine which strings belong to L∗L^*, we check if they can be partitioned into a sequence of substrings from L={ab,aa,baa}L = \{ab, aa, baa\}.

  • String 1: abaabaaabaaabaabaaabaa
    Partition: (ab)⋅(aa)⋅(baa)⋅(ab)⋅(aa)(ab) \cdot (aa) \cdot (baa) \cdot (ab) \cdot (aa)
    Since all components are in LL, this string is in L∗L^*.
  • String 2: aaaabaaaaaaaabaaaa
    Partition: (aa)⋅(aa)⋅(baa)⋅(aa)(aa) \cdot (aa) \cdot (baa) \cdot (aa)
    Since all components are in LL, this string is in L∗L^*.
  • String 3: baaaaabaaaabbaaaaabaaaab
    This string ends with bb. Since abab is the only element in LL ending with bb, the string must end with the token abab, leaving the prefix baaaaabaaabaaaaabaaa (ba5ba3b a^5 b a^3).
    Any block starting with bb must begin with baabaa (the only element starting with bb) followed by some number of aaaa tokens, which always produces an even number of aa's (ba2n+2b a^{2n+2}). However, the first block has 55 aa's (ba5b a^5), which is odd and cannot be formed. Thus, this string is not in L∗L^*.
  • String 4: baaaaabaabaaaaabaa
    Partition: (baa)⋅(aa)⋅(ab)⋅(aa)(baa) \cdot (aa) \cdot (ab) \cdot (aa)
    Since all components are in LL, this string is in L∗L^*.

Therefore, strings 1, 2, and 4 are in L∗L^*.

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

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