CS321 Theory of Computation Midterm, Fall 2014
CS321 Theory of Computation Midterm, Fall 2014
Theory of Computation
Midterm, Fall 2014
Name:
L(M ) = {ava : v ∈ Σ∗ }.
So for example aaaaa, abbbbb, abccc are in L(N ), but aba, aab,
and abcb are not in L(N ).
(c) [5pt] Draw a DFA or NFA M with alphabet Σ = {a, b} such that
L(M ) = {w : w ∈ Σ∗ , na (w) mod 2 = 0}.
2. (a) [5pt] Write a regular expression r such that
L(r) = {w : w = am bn , m + n is even}
.
r = (aa)*(bb)* + a(aa)*b(bb)*
r = (b*ab*ab*)*
r = w1 + w2 + ... + w_n
L(r) = {w1,w2,...,w_n} = L
L(r)=L(r1)L(r2)=L1L2.
This shows that r is an RE for L1L2 and hence that L1L2 is regular.
Construct an RE r' by starting with r and then replacing each 'a' in r with 'cc'.
It is clear that L(r') = REPLACE(L). This is because r' will insert a 'cc' in a string
exactly when r would have inserted an 'a' in a string.
A similar argument could be made by starting with an NFA N such that L=L(N).
Now create a new NFA N' that starts with N but replaces any arc labeled by an
'a' with two consecutive arcs, each labeled by a 'c'. The picture below illustrates
the process for one transition, noting that q' is a new state that is introduced into
N'.
(b) [5pt] Use the procedure taught in class or the book to convert the
following NFA to an equivalent DFA.
Start q0 λ q1 b q2 b q3
b b a
q4 q5
5. (a) [5pt] Consider the following NFA N .
a b
Start q0 q1 q2
b
b a a
b
q3
(ba*)*(a+b)(bb + b*a(ba*)*(a+b))*