GATE / CS ARCHIVE

GATE CSE 2003 / QUESTION 50

Counting constrained binary strings accepted by a DFA

Theory of Computation · Finite Automata · Full GATE CSE 2003 paper

GATE 2003, Q50 2 marks · MCQ
Report issue

Finite Automata

Question 50, GATE 2003: A DFA over {0,1} has states q0 (start), q1, q2 and q3 (the only accepting state). Transitions: q0 on 1→q0 and 0→q1; q1 on 1→q0 and 0→q2; q2 on 0→q2 and 1→q3; q3 on either symbol→q3. Let S contain seven-bit strings whose first, fourth and last bits are 1. How many strings of S are accepted?
A. 1  B. 5  C. 7  D. 8
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Reaching q2 requires two consecutive zeros; after reaching q2 a later 1 enters the absorbing accepting state q3.
2. Strings of S have form 1xy1zw1, leaving four free bits and 16 total strings. Adjacent zeros can occur only as xy=00 or zw=00, because fixed 1s separate the blocks.
3. Fixing xy=00 leaves four choices for zw; fixing zw=00 leaves four choices for xy. The string 1001001 is counted twice. Inclusion–exclusion yields 4+4−1=7, so C.

Solution: The DFA accepts precisely strings that contain two consecutive zeros followed later by a one. With positions 1,4,7 fixed to one, a qualifying pair of zeros must occupy positions 2–3 or 5–6, and the following fixed one guarantees acceptance. Of the 16 assignments to the four free bits, four have the first zero pair, four have the second, and one has both. Inclusion–exclusion gives 4+4−1=7 accepted strings, option C.

Original paper, page 7