GATE / CS ARCHIVE

GATE CSE 2014 SET 3 / QUESTION 15

GATE CSE 2014 Set 3 Q15

Theory of Computation · Regular Expressions & Languages · Full GATE CSE 2014 Set 3 paper

GATE 2014 Set 3, Q15 1 mark · NAT
Report issue

Regular Expressions & Languages

Question 15, GATE 2014: Over alphabet {a,b}, consider the regular expression a*b*(ba)*a*. What is the length of a shortest string outside its language?
Tap to enlarge
Answer & solution

Official answer: 3

Step 1: A shortest counterexample requires checking every shorter length. The empty string is obtained by choosing zero repetitions everywhere; a and b are generated by their star factors. Step 2: All length-two strings occur: aa from a*, ab from a*b*, bb from b*, and ba from (ba)*. Step 3: The length-three word bab is absent. Without any ba pair, a*b*a* cannot switch back to b after a trailing a. If a ba pair is used, the remaining final b cannot be produced by the final a*, and extra pairs are too long. Step 4: Hence no shorter string is missing, while bab is missing, so the answer is 3.

Original paper, page 56 · Answer key