Give a finite state diagram for a DFA that accepts any word in the language L = {w | w ∈ {a, b}∗ and w alternates a’s and b’s and has an even number of b’s}.
My attempt: I am having problem on how to deal with the even part of b.
Give a finite state diagram for a DFA that accepts any word in the language L = {w | w ∈ {a, b}∗ and w alternates a’s and b’s and has an even number of b’s}.
My attempt: I am having problem on how to deal with the even part of b.
The language contains strings that are of odd length too. Namely, the strings with an even number of b's and one more or one less a, and alternating a's and b's. This language cannot be accepted by a finite state automaton with only two states. If an automaton is made with two states with a's transitioning to the same state, then that automaton would accept strings of arbitrary numbers of consecutive a's which do not belong in the language, since there is no alternation.
The FSA to accept this language is given below, and the labels explain what each state represents.