GATE / CS ARCHIVE

GATE CSE 2022 / QUESTION 12

GATE CSE 2022 Q12

Theory of Computation · Regular Expressions & Languages · Full GATE CSE 2022 paper

GATE 2022, Q12 1 mark · MCQ
Report issue

Regular Expressions & Languages

Question 12, GATE 2022: An NFA has nonfinal start s and final states u,v. Transitions: s—a→u, s—b→v, u—b→u and s, v—a→v and s; no other transitions. Choose its regular expression (plus means union): A ab*bab*+ba*aba*; B (ab*b)*ab*+(ba*a)*ba*; C (ab*b+ba*a)*(a*+b*); D (ba*a+ab*b)*(ab*+ba*).
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Each return to the nonaccepting start state consumes either ab*b through the upper accepting state or ba*a through the lower one. Any number of such excursions may occur. Finally the path must stop in an accepting state, consuming ab* or ba*. Thus the language is (ba*a+ab*b)*(ab*+ba*), D.

A useful state-elimination decomposition is a sequence of complete excursions back to s, then one final unfinished excursion into u or v. Since s is nonaccepting, the final factor must consume at least one symbol; option C incorrectly admits ε. Option B disallows mixing the two types of returning excursion before the last segment.

Original paper, page 11 · Answer key