# HW2Sol by wuzhengqin

VIEWS: 7 PAGES: 7

• pg 1
```									  CS311 / MATH352 - AUTOMATA AND COMPLEXITY THEORY
Homework # 2
Max. Points: 100
Due Date: Monday, December 31, 2007 5:00PM

Student’s Name: _____________________________________Student ID: __________

Important Instructions
You are required to get print-out of this homework, and solve it using the space
provided against each question. You are not allowed to solve on other papers, as you
did in previous assignment.
Clearly state your assumptions, if you are assuming some thing in addition to the
given information in each question.
Avoid copying work of another person. If found, then such case would be forwarded
for disciplinary action without any warning / justification.
Drop your homework in the box labeled “CS311 HW 2” in CS department. Any
assignment submitted at 5:01PM will not be accepted.
And Best of Luck!!!

Problem No. 1 (15*4=60 points)
Decide whether the following statements are True or False. You must justify your
i)      An NFA may also be a DFA.

True. Because every DFA is by default an NFA. If we think about such an NFA, it’s
also a DFA.

ii)    A DFA is also an NFA.

True. A DFA is an NFA which doesn’t use the non-determisnism property.

1
iii)    A DFA with a single final state must accept at least one string (and that one
string may be an empty string).

False. That single final state may not be reachable from start state.

iv)     A DFA which contains cycles always recognizes a language containing
infinite number of strings.

False. We may have a DFA which contains cycle but the states involved cycle are
not reachable from start state.

v)      We can convert every NFA into an equivalent DFA except the NFA which
accepts empty language.
False. All NFA’s can be converted into an equivalent DFA.

vi)     We can convert every NFA into an equivalent DFA except the NFA which
accepts empty string.

False. All NFA’s can be converted into an equivalent DFA.

2
vii)    If L1={}and L2={λ}, then L1=L2.

False. L1 contains no string but L2 contains one string.

viii)   If L1={} and L3= Φ, then L1=L3.

True. Both represent the same language but with different notation.

ix)     If L2={λ} and L3= Φ, then L2=L3.

False. L2 has one string but L3 has no string.

x)      If L1 is a regular language and L2 is a finite language then L1∩L2 is also finite.

True. Intersection contains common strings, and finite language will have finite
string so. Only finite strings may be common.

3
xi)     If L1 is a regular language and L2 is a finite language then L1UL2 is also finite.

False. Counter example:
L1={(a+b)*}, L2={a}, union will be equal to L1.

xii)    If L1 and L2 are infinite regular languages then it is possible that L1∩L2 is
finite.

True. L1={a*}, L2={b*}, intersection will be { λ}.

xiii)   For some infinite regular languages, we may have to construct a very large
DFA containing infinite number of states but no cycles.

False. DFA can’t have infinite number of states.

xiv)    If L1 and L2 are infinite regular languages then it is possible that L1∩L2 is
finite.

True. L1={a*}, L2={b*}, intersection will be { λ}.

4
xv)     There may be some non-regular language containing finite number of strings
of random pattern.

False. All finite languages are regular.

Problem No. 2 (5*5=25 points)
Write regular expressions and draw DFA’s for each of the following languages over the
alphabet {0,1,2}:
a) L1 = {w | w has length at least 3 and its 3rd symbol is 0}

(0+1+2)(0+1+2)0(0+1+2)*

b) L2 = {w | the length of w is at most 4}
λ +(0+1+2)+ (0+1+2)(0+1+2)+ (0+1+2) (0+1+2) (0+1+2)+ (0+1+2) (0+1+2) (0+1+2)
(0+1+2)

c) L3 = {w | w is any string except 012}
λ+0+01+(1+2)(0+1+2)*+00(0+1+2)*+02(0+1+2)*+010(0+1+2)*+011(0+1+2)*+012(0+
1+2)+

5
d) L4 = {w | Every odd position of w is 2}
λ +2[(0+1+2)2]*( λ+0+1+2)

e) L5 = {w | w starts with a 2 and has odd length, or w ends with a 0 and has even
length}
2[(0+1+2)(0+1+2)]* + (0+1+2)[(0+1+2)(0+1+2)]*0

6
Problem No. 3 (15 points)
Prove or disprove: If M is an NFA that recognizes a language D, swapping the accept
states and non-accept states in M, always yields a new NFA that recognizes the
complement of D. We already know that all NFA’s recognize only regular languages and
regular languages are closed under complement.

Above statement is false. Here is a counter example. Consider the following NFA:

After swapping final and non-final states, we get following NFA which also accept
empty string which was accepted in the original NFA.

7

```
To top