GATE / CS ARCHIVE

GATE CSE 2001 / QUESTION 5(b)

DFA for odd counts of both letters

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

GATE 2001, Q5(b) Descriptive
Report issue

Finite Automata

Question 5(b), GATE 2001: Alphabet {a,b}; accept strings with an odd number of a symbols and an odd number of b symbols.

Task: Construct a DFA for this language.
Question 5(b), GATE 2001: Alphabet {a,b}; accept strings with an odd number of a symbols and an odd number of b symbols.

Task: Construct a DFA for this language.
Tap to enlarge
Shared context

Alphabet {a,b}; accept strings with an odd number of a symbols and an odd number of b symbols.

Answer & solution

Answer: Four parity states EE, OE, EO, OO; start EE, sole accepting OO. a toggles first component, b toggles second. (no official key was published)

Step through it (2 parts)

1. Only the two parities matter, so use states (parity of a count, parity of b count). The empty string has counts zero and zero, making EE the start state.

2. Reading a increments only the a count and toggles its parity. Reading b toggles only the b parity. Complete transition table on (a,b): EE→(OE,EO); OE→(EE,OO); EO→(OO,EE); OO→(EO,OE).

3. Mark only OO accepting. By induction on the processed prefix, the stored pair equals its two actual count parities: the base is EE and every transition applies the correct single parity toggle.

4. Therefore a string is accepted exactly when both counts are odd. For instance ab ends in OO, whereas aab ends in EO and is rejected.

Original paper, page 7