GATE / CS ARCHIVE

GATE CSE 1994 / QUESTION 2.10

Regex from an automaton with a trap

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

GATE 1994, Q2.10 Other
Report issue

Regular Expressions & Languages

Question 2.10, GATE 1994: Start/accept state A loops on 0 and goes to accept B on 1. B loops on 1 and goes to nonaccepting trap C on 0; C loops on both. Give a regex.
Tap to enlarge
Answer & solution

Answer: 0*1* (no official key was published)

While in A the machine reads any number of zeros, possibly none. The first one moves it to B, where further ones are allowed. A zero after that moves to the trap and cannot be recovered. Thus accepted words are exactly a block of zeros followed by a block of ones, with either block allowed empty: 0*1*. The empty word is accepted because the start state A is accepting. The accepting mark on B permits words ending after one or more ones.

Original paper, page 4