Regular Expressions & Languages

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.