GateAI
Regular Expressions and Finite Automata

GATE CSE 2014 Set 3 · Q15

NAT1 markMedium

Time

The length of the shortest string NOT in the language (over Σ={a,b}\Sigma = \{a, b\}) of the following regular expression is _______. a∗b∗(ba)∗a∗a^*b^*(ba)^*a^*

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 3

Regular Expressions and Finite Automata

Let the given regular expression be R=a∗b∗(ba)∗a∗R = a^*b^*(ba)^*a^*.

Let us test strings generated by RR of various lengths:

  1. Length 0:

    • ϵ\epsilon is generated by choosing all exponents as 00.

  2. Length 1:

    • aa: generated by a1b0(ba)0a0a^1 b^0 (ba)^0 a^0

    • bb: generated by a0b1(ba)0a0a^0 b^1 (ba)^0 a^0

    All strings of length 1 are in L(R)L(R).

  3. Length 2:

    • aaaa: generated by a2a^2

    • abab: generated by a1b1a^1 b^1

    • baba: generated by (ba)1(ba)^1

    • bbbb: generated by b2b^2

    All strings of length 2 are in L(R)L(R).

  4. Length 3:

    • aaaaaa: generated by a3a^3

    • aabaab: generated by a2b1a^2 b^1

    • abaaba: generated by a1(ba)1a^1 (ba)^1

    • abbabb: generated by a1b2a^1 b^2

    • baabaa: generated by (ba)1a1(ba)^1 a^1

    • babbab: generated by b1(ba)1b^1 (ba)^1

    • bbabba: generated by b2a1b^2 a^1 (via b2(ba)0a1b^2 (ba)^0 a^1)

    • bbbbbb: generated by b3b^3

    Wait, let's check babbab: To form babbab, we could try:

    • a∗b∗(ba)∗a∗a^*b^*(ba)^*a^*: if we pick b1b^1 from b∗b^* and a1a^1 from (ba)∗(ba)^*, that gives baba, followed by bb? But (ba)∗(ba)^* only gives strings with alternating baba.

    • Let us check if babbab can be generated:

      • If from (ba)∗(ba)^* we pick (ba)1=ba(ba)^1 = ba, we have a∗b∗(ba)a∗a^*b^*(ba)a^*. To make babbab, the last letter must be bb, but after (ba)(ba) only a∗a^* is available, which cannot produce bb.

      • If (ba)∗(ba)^* is ϵ\epsilon, we have a∗b∗a∗a^*b^*a^*, which cannot produce babbab since the pattern is a…ab…ba…aa\dots ab\dots ba\dots a (contains at most one transition from bb to aa, and no bb after the final aa's).

    • Thus, babbab cannot be generated by a∗b∗(ba)∗a∗a^*b^*(ba)^*a^*.

Since all strings of length 0,1,20, 1, 2 are in L(R)L(R), the length of the shortest string not in the language is 3.

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 Q15 of the GATE CSE 2014 Set 3 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. 5 of them are 1-mark NAT questions like this one, and it is the only one in GATE CSE 2014 Set 3.

How GATE tests Regular Expressions and Finite Automata

More from GATE CSE 2014 Set 3

Share this solution

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

GateAI solution cardGATE CSE 2014 Set 3 · Q15 · NAT

The length of the shortest string NOT in the language (over = {a, b}) of the following regular expression is … a*b*(ba)*a*

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.