GateAI
Regular Expressions and Finite Automata

GATE CSE 2024 Set 1 · Q61

NAT2 marksMedium

Time

Consider the following two regular expressions over the alphabet {0,1}\{0,1\}: r=0∗+1∗r = 0^* + 1^* s=01∗+10∗s = 01^* + 10^* The total number of strings of length less than or equal to 5, which are neither in rr nor in ss, is ________

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 44

Regular Expressions and Finite Automata

Let Σ={0,1}\Sigma = \{0, 1\}.

  1. Total number of strings of length ≤5\le 5: The total number of binary strings of length kk is 2k2^k.

    ∑k=052k=1+2+4+8+16+32=63\sum_{k=0}^{5} 2^k = 1 + 2 + 4 + 8 + 16 + 32 = 63
  2. **Strings in L(r)=L(0∗+1∗)L(r) = L(0^* + 1^*) of length ≤5\le 5:**

    • Length 0: ϵ\epsilon (1 string)

    • Length 1: 0,10, 1 (2 strings)

    • Length 2: 00,1100, 11 (2 strings)

    • Length 3: 000,111000, 111 (2 strings)

    • Length 4: 0000,11110000, 1111 (2 strings)

    • Length 5: 00000,1111100000, 11111 (2 strings)

    Total in L(r)L(r) of length ≤5\le 5 is 1+2×5=111 + 2 \times 5 = 11 strings.

  3. **Strings in L(s)=L(01∗+10∗)L(s) = L(01^* + 10^*) of length ≤5\le 5:**

    • Length 1: $0, 1$ (already in $L(r)$)

    • Length 2: 01,1001, 10 (2 new strings)

    • Length 3: 011,100011, 100 (2 new strings)

    • Length 4: 0111,10000111, 1000 (2 new strings)

    • Length 5: 01111,1000001111, 10000 (2 new strings)

    Number of distinct strings in L(s)∖L(r)L(s) \setminus L(r) of length ≤5\le 5 is 2×4=82 \times 4 = 8 strings.

  4. Total strings in L(r)∪L(s)L(r) \cup L(s) of length ≤5\le 5:

    ∣L(r)∣+∣L(s)∖L(r)∣=11+8=19|L(r)| + |L(s) \setminus L(r)| = 11 + 8 = 19
  5. Strings of length ≤5\le 5 neither in rr nor in ss:

    63−19=4463 - 19 = 44

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 Q61 of the GATE CSE 2024 Set 1 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 1 has 2.

How GATE tests Regular Expressions and Finite Automata

More from GATE CSE 2024 Set 1

Share this solution

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

GateAI solution cardGATE CSE 2024 Set 1 · Q61 · NAT

Consider the following two regular expressions over the alphabet {0,1}: r = 0* + 1* s = 01* + 10* The total number of strings of length less than or equal to 5, which are neither in r nor in s, 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.