GateAI
Regular Expressions and Finite Automata

GATE CSE 2024 Set 2 · Q62

NAT2 marksMedium

Time

Let L1L_1 be the language represented by the regular expression b∗ab∗(ab∗ab∗)∗b^*ab^*(ab^*ab^*)^* and L2={w∈(a+b)∗∣∣w∣≤4}L_2 = \{ w \in (a + b)^* \mid |w| \le 4 \}, where ∣w∣|w| denotes the length of string ww. The number of strings in L2L_2 which are also in L1L_1 is _________

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 15

Regular Expressions and Finite Automata
  1. Language L1L_1: The regular expression b∗ab∗(ab∗ab∗)∗b^*ab^*(ab^*ab^*)^* represents all strings over {a,b}\{a, b\} that contain an odd number of aa's.

  2. Language L2L_2: L2L_2 contains all strings over {a,b}\{a, b\} of length at most 4 (i.e., ∣w∣≤4|w| \le 4).

  3. Intersection L1∩L2L_1 \cap L_2: We need to count strings of length ∣w∣≤4|w| \le 4 having an odd number of aa's (which means either 1 or 3 occurrences of aa):

    • Length 0 (∣w∣=0|w| = 0): 0 strings.

    • Length 1 (∣w∣=1|w| = 1): Exactly 1 'aa'   ⟹  (11)=1\implies \binom{1}{1} = 1 string (a).

    • Length 2 (∣w∣=2|w| = 2): Exactly 1 'aa'   ⟹  (21)=2\implies \binom{2}{1} = 2 strings (ab, ba).

    • Length 3 (∣w∣=3|w| = 3):

      • 1 'aa': (31)=3\binom{3}{1} = 3 strings

      • 3 'aa's: (33)=1\binom{3}{3} = 1 string

      • Total = 3+1=43 + 1 = 4 strings.

    • Length 4 (∣w∣=4|w| = 4):

      • 1 'aa': (41)=4\binom{4}{1} = 4 strings

      • 3 'aa's: (43)=4\binom{4}{3} = 4 strings

      • Total = 4+4=84 + 4 = 8 strings.

  4. Total Count:

    1+2+4+8=151 + 2 + 4 + 8 = 15

Thus, the number of strings in L2L_2 which are also in L1L_1 is 15.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Regular Expressions and Finite Automata previous year question is Q62 of the GATE CSE 2024 Set 2 paper. Find more GATE CSE PYQs on Regular Expressions and Finite Automata in Theory of Computation, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Regular Expressions and Finite Automata PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Regular Expressions and Finite Automata in GATE CSE

Regular Expressions and Finite Automata has 41 GATE CSE PYQs across 24 papers from 2011 to 2026. 6 of them are 2-mark NAT questions like this one, and GATE CSE 2024 Set 2 has 3.

How GATE tests Regular Expressions and Finite Automata

More from GATE CSE 2024 Set 2

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2024 Set 2 · Q62 · NAT

Let L1 be the language represented by the regular expression b*ab*(ab*ab*)* and L2 = { w ∈ (a + b)* |w| ≤ 4 }, where |w| denotes the length of string w. The number of strings in L2 which are also in L1 is …

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.