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
GATE CSE 2014 Set 3 · Q15
Time
Your answerNumerical answer
Solution
Official answer: 3
Regular Expressions and Finite AutomataLet the given regular expression be .
Let us test strings generated by of various lengths:
Length 0:
is generated by choosing all exponents as .
Length 1:
: generated by
: generated by
All strings of length 1 are in .
Length 2:
: generated by
: generated by
: generated by
: generated by
All strings of length 2 are in .
Length 3:
: generated by
: generated by
: generated by
: generated by
: generated by
: generated by
: generated by (via )
: generated by
Wait, let's check : To form , we could try:
: if we pick from and from , that gives , followed by ? But only gives strings with alternating .
Let us check if can be generated:
If from we pick , we have . To make , the last letter must be , but after only is available, which cannot produce .
If is , we have , which cannot produce since the pattern is (contains at most one transition from to , and no after the final 's).
Thus, cannot be generated by .
Since all strings of length are in , the length of the shortest string not in the language is 3.
Try the question first, then check your work.
Examiner trap
Check strings of length 0, 1, 2, and 3 systematically. Notice that any after an can only come from the factor.
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
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.
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 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 AutomataIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.