Problem
Problem
= {a, b}. The language of all strings containing exactly two a’s. The language of all
strings containing at least two a’s. The language of all strings that do not end with ab.
The language of all strings that begin or end with aa or bb. The language of all strings
not containing the substring aa. The language of all strings in which the number of a’s
is even. The language of all strings in which both the number of a’s and the number of
b’s are even. The language of all strings containing no more than one occurrence of
the string aa. (The string aaa contains two occurrences of aa.) The language of all
strings in which every a (if there are any) is followed immediately by bb. The language
of all strings containing both bb and aba as substrings.
1. To draw an FA accepting the language of all strings containing exactly two a's, we can
design a finite automaton as follows:
o Start with a single initial state.
o Create two states, one for each occurrence of 'a'.
o Connect the initial state to the first 'a' state with a transition labeled 'a'.
o From the first 'a' state, create a transition labeled 'a' to the second 'a' state.
o From the second 'a' state, create a transition labeled any character in Σ to a non-
accepting state.
o If the automaton ends in the second 'a' state, it is an accepting state.
2. The language of all strings containing at least two a's can be accepted by the following
FA:
o Start with a single initial state.
o Create two states, one for each occurrence of 'a'.
o Connect the initial state to the first 'a' state with a transition labeled 'a'.
o From the first 'a' state, create a transition labeled 'a' to the second 'a' state.
o From the second 'a' state, create transitions labeled any character in Σ to a non-
accepting state or back to the second 'a' state.
o The second 'a' state is an accepting state.
3. To draw an FA accepting the language of all strings that do not end with 'ab', we can
design a finite automaton as follows:
o Start with a single initial state.
o Create two states, one for each character in Σ.
o Connect the initial state to each state with transitions labeled with the corresponding
character.
o From the state corresponding to 'a', create a transition labeled 'b' to a non-accepting
state.
o From the state corresponding to 'b', create transitions labeled any character in Σ to a
non-accepting state.
o If the automaton ends in any state other than the one corresponding to 'b', it is an
accepting state.
4. The language of all strings that begin or end with 'aa' or 'bb' can be accepted by the
following FA:
o Start with a single initial state.
o Create two states for each occurrence of 'aa' or 'bb', totaling four states.
o Connect the initial state to the first 'aa' state with a transition labeled 'a'.
o From the first 'aa' state, create a transition labeled 'a' to the second 'aa' state.
o From the second 'aa' state, create transitions labeled any character in Σ to a non-
accepting state or back to the second 'aa' state.
o Repeat the same process for 'bb'.
o The second 'aa' state and the second 'bb' state are accepting states.
5. To draw an FA accepting the language of all strings not containing the substring 'aa', we
can design a finite automaton as follows:
o Start with a single initial state.
o Create two states, one for each character in Σ.
o Connect the initial state to each state with transitions labeled with the corresponding
character.
o From the state corresponding to 'a', create a transition labeled 'a' back to the initial
state.
o From the state corresponding to 'b', create a transition labeled any character in Σ to a
non-accepting state or back to the state corresponding to 'b'.
o The initial state is an accepting state.
6. The language of all strings in which the number of 'a's is even can be accepted by the
following FA:
o Start with a single initial state.
o Create two states, one for even and one for odd number of 'a's.
o Connect the initial state to the even state with a transition labeled 'a', and from the even
state to the odd state with a transition labeled 'a'.
o From the odd state, create transitions labeled 'a' back to the even state and transitions
labeled any character in Σ to a non-accepting state.
o The even state is an accepting state.
7. To draw an FA accepting the language of all strings in which both the number of 'a's
and the number of 'b's are even, we can design a finite automaton as follows:
o Start with a single initial state.
o Create four states, representing even or odd numbers of 'a's and 'b's.
o Connect the initial state to the even 'a' state with a transition labeled 'a', and from the
even 'a' state to the odd 'a' state with a transition labeled 'a'.
o Repeat the same process for 'b'.
o From the odd 'a' or 'b' states, create transitions labeled any character in Σ to a non-
accepting state or back to the corresponding even state.
o The even 'a' and 'b' states are accepting states.
8. The language of all strings containing no more than one occurrence of the string 'aa'
can be accepted by the following FA:
o Start with a single initial state.
o Create two states for each occurrence of 'aa', totaling four states.
o Connect the initial state to the first 'aa' state with a transition labeled 'a'.
o From the first 'aa' state, create a transition labeled 'a' to the second 'aa' state.
o From the second 'aa' state, create transitions labeled any character in Σ to a non-
accepting state or back to the second 'aa' state.
o Repeat the same process for the second occurrence of 'aa'.
o The second 'aa' states and the states corresponding to 'a' and 'b' after the second 'aa'
are accepting states.
9. To draw an FA accepting the language of all strings in which every 'a' (if there are any)
is followed immediately by 'bb', we can design a finite automaton as follows:
o Start with a single initial state.
o Create two states, one for 'a' and one for 'b'.
o Connect the initial state to the 'a' state with a transition labeled 'a', and from the 'a' state
to the 'b' state with a transition labeled 'bb'.
o From the 'b' state, create transitions labeled any character in Σ to a non-accepting state
or back to the 'a' state.
o The 'b' state is an accepting state.
10. The language of all strings containing both 'bb' and 'aba' as substrings can be accepted
by the following FA:
o Start with a single initial state.
o Create three states, one for 'b', one for 'a', and one for 'b' followed by 'a'.
o Connect the initial state to the 'b' state with a transition labeled 'b'.
o From the 'b' state, create a transition labeled 'b' to the 'ba' state.
o From the 'ba' state, create a transition labeled 'a' to the 'aba' state.
o From the 'aba' state, create transitions labeled any character in Σ to a non-accepting
state or back to the 'b' state.
o The 'aba' state is an accepting state.
Note that the above FA designs are just examples, and there may be alternative
designs that also accept the given languages.