CMPS 260 Spring 2022
Homework #3: Nondeterministic Finite Automata
Due: 2pm, Wednesday March 2

Each of the first five problems describes a language and asks you to present an NFA —with a specified maximum number of states and/or transitions— that accepts that language. In counting states and transitions, you need not include the dead state or any transitions directed to it. Nor do you need to show that state or those transitions, as it is understood that if, in a transition graph, a state q has no outgoing transition on a symbol a, it is as though there were such a transition and it went to the dead state.

1. Present an NFA having at most five states and eight transitions that accepts the language

L1 = { x010y1  |  x,y ∈ {0,1}* }

In words, L1 contains precisely those strings over the alphabet {0,1} having 010 as a substring and 1 as a suffix.

Note that a transition labeled by both 0 and 1 counts as two transitions.


2. Present an NFA having at most six states and at most nine transitions that accepts the language

L2 = { w ∈ {0,1}*  |  w = x0011 for some x ∈ {0,1}*  ∨  w = x000y for some x,y ∈ {0,1}*}

In words, L2 contains precisely those strings over the alphabet {0,1} having either 0011 as a suffix or 000 as a substring.

Note that a transition labeled by both 0 and 1 counts as two transitions.


3. Present an NFA having at most seven states that accepts the language

L3 = { ucv  |  u,v ∈ {a,b}*} ∪ { ubv  |  u,v ∈ {a,c}*} ∪ { uav  |  u,v ∈ {b,c}*}

In words, L3 contains precisely those strings over the alphabet {a,b,c} in which at least one among the three symbols appears exactly once.


4. Present an NFA having at most eight states (only one final state is necessary) that accepts the language

L4 = { w0011v  |  w,v ∈ {0,1}* ∧ |v| ≥ 3} ∪ { w00v  |  w,v ∈ {0,1}* ∧ |v| = 2}

In words, L4 contains precisely those strings over {0,1} that end either at least three symbols after an occurrence of 0011 or exactly two symbols after an occurrence of 00.


5. Present an NFA having four states and only five non-λ transitions that accepts the language

L5 = { {aa} ∪ {aba} ∪ {ac} ∪ {acc} }*

In words, L5 contains precisely those strings over {a,b,c} that can be "factored" into a sequence of zero or more substrings, where each factor is either aa, aba, ac, or acc. An example of such a string (in which vertical bars have been inserted in order to show the boundaries between adjacent factors) is

ac|aba|aa|ac|acc|aa|aa|acc|aba|aa

You will find it helpful to use at least one λ transition, and maybe more.



6. Construct a λ-free NFA that is equivalent to (i.e., accepts the same language as) the NFA shown below. Present your answer in tabular form (as on the right side of the figure below) rather than as (or in addition to, if you want) a transition graph. Don't forget to identify the initial state and the final states.

An appropriate algorithm for removing λ-transitions is described in the section titled Step 1 in the web page that describes the Subset Construction algorithm (by which to obtain a DFA equivalent to a given NFA).

Transition Graph Table
Init?Final?State δ(_,a)δ(_,b)δ(_,λ)
q0 {q1}
q1{q0} {q2}
q2{q2} {q3} {q3}
q3 {q4}
q4 {q0} {q1}


7. Present the DFA obtained by applying the Subset Construction algorithm to the NFA shown below. It should have six states.

Present your answer in tabular form (as on the right side of the figure below) rather than as (or in addition to, if you want) a transition graph. Don't forget to identify the initial state and the final states.

Your DFA's state names should make obvious which subset of the NFA's state set each one corresponds to. For example, q{0,2} (or simply {0,2}, if you prefer) could be the name of the state corresponding to the set of states {q0, q2} in the given NFA.

Transition Graph Table
Init?Final?State δ(_,a)δ(_,b)
q0{q1,q2} {q2}
q1{q1} {q3}
q2{q0} {q2,q3}
q3{q1} {q1}