Let 𝐿1 be the language represented by the regular expression 𝑏∗𝑎𝑏∗…

2024

Let 𝐿1 be the language represented by the regular expression 𝑏𝑎𝑏 (𝑎𝑏𝑎𝑏) and 𝐿2 = { 𝑤 ∈ (𝑎 + 𝑏) | |𝑤| ≤ 4}, where |𝑤| denotes the length of string 𝑤. The number of strings in 𝐿2 which are also in 𝐿1 is ___________

Attempted by 80 students.

Show answer & explanation

Correct answer: 15

Key insight: the language L1 consists exactly of all strings over {a,b} that contain an odd number of a's (at least one).

Reason: The expression b* a b* (a b* a b*)* has one initial a and each repetition adds two a's, so the total number of a's is 1 + 2k (always odd).

  • Length 0: 0 strings in L1 (no a's).

  • Length 1: 1 string with an odd number of a's (a).

  • Length 2: 2 strings with an odd number of a's (exactly one a).

  • Length 3: 4 strings with an odd number of a's.

  • Length 4: 8 strings with an odd number of a's.

Total: 1 + 2 + 4 + 8 = 15 strings.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir