The finite state machine given in figure below recognizes :
2018
The finite state machine given in figure below recognizes :

- A.
any string of odd number of a’s
- B.
any string of odd number of b’s
- C.
any string of even number of a’s and odd number of b’s
- D.
any string of odd number of a’s and odd number of b’s
Attempted by 240 students.
Show answer & explanation
Correct answer: D
Key idea: each state encodes the parity (even or odd) of the number of a's and b's seen so far.
Start state = (even a, even b).
Top-right state = (odd a, even b).
Bottom-left state = (even a, odd b).
Bottom-right (accepting) = (odd a, odd b).
Transitions:
Reading 'a' flips the a-parity and moves horizontally between top and bottom pairs.
Reading 'b' flips the b-parity and moves vertically between left and right pairs.
Conclusion: the machine accepts exactly those strings where both the number of a's and the number of b's are odd (i.e., parity(a)=odd and parity(b)=odd).
Examples:
Accepted: "ab" (start -> read a -> read b -> bottom-right accepting).
Rejected: "a" (one a but zero b -> ends in non-accepting state).
A video solution is available for this question — log in and enroll to watch it.