How would I go about designing a deterministic finite automata to recognize the language
L = {λ, ab, abab, ababab, . . . }
consisting of strings that start with ‘a’, end with ‘b’, and alternate in between? Any help or push in the right direction is appreciated.
You asked “How would I go about designing…”. You should imagine that someone has given you a very long string of symbols and asked you to verify this property. The string is so long—perhaps thousands or millions of symbols—so that you cannot simply see it at a glance, as you can with short strings like
ababab. Then ask yourself what you could do to decide if the string has the required property.Usually your idea will look something like this: “First I'll do (something), and then if I see an
aI will do (something else), but if it's abI will look at the next symbol, and then if it's anaI will do (some other thing).” The decision points where you say “I look at the next symbol and if it'saI'll do (this) but if it'sbI'll do (that)” are exactly the states of a finite automaton:Here's an example which isn't the one from your question: Say I would like to check to see if a string contains two consecutive
as. How can I do this? I should scan the string starting with the first character. If I see ana, I will look to see if the next character is alsoa; if it is, the string has two consecutiveas, so I will accept. If I see something else while looking for ana, I will continue scanning the string. And once I have seen twoas, nothing else I see in the string will cause me to reject it: