-1

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.

max
  • 167
  • 2
  • 9
  • 2
    One way to think about designing DFAs is to identify states with a meaning. In this case, you'll need 2 states. One means "an even number of b's have been seen" and the other is the same for an odd number of b's. Since zero is even, that state is the start state. And since you want strings of even length, it's also the (only) accepting state. Now add transitions based on the meanings, and you're done. E.g. since a's don't affect the number of b's seen, each state transitions to itself on input 'a'. So you only need to add the 'b' transitions. – Gene Nov 30 '15 at 01:04
  • As a starting point, please show us your DFA that accepts every string w that alternates a's and b's – Nayuki Nov 30 '15 at 01:17
  • what is your minimum string...null or blank and only (a). – Divyesh Jesadiya Dec 08 '15 at 07:45

1 Answers1

0

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.enter image description here

SwiftMatt
  • 949
  • 1
  • 9
  • 19