COMP 3803 - Assignment 1
COMP 3803 - Assignment 1
• Your assignment must be submitted as one single PDF file through cuLearn.
• Late assignments will not be accepted. I will not reply to emails of the
type “my internet connection broke down at 23:57” or “my scanner stopped
working at 23:58”, or “my dog ate my laptop charger”.
• You are encouraged to collaborate on assignments, but at the level of discussion only.
When writing your solutions, you must do so in your own words.
• Past experience has shown conclusively that those who do not put adequate effort into
the assignments do not learn the material and have a probability near 1 of doing poorly
on the exams.
• When writing your solutions, you must follow the guidelines below.
When specifying a finite automaton, it is sufficient to draw the state diagram (be-
cause this diagram tells us what are the alphabet, the set of states, the start state,
the set of accept states, and the transition function).
Question 2: For each of the following languages, construct a DFA that accepts the language.
In all cases, the alphabet is {0, 1}. For each DFA, justify correctness.
(2.1) {w ∈ {0, 1}∗ : w starts with 1 and ends with 0}.
(2.2) {w ∈ {0, 1}∗ : every odd position in w is 1}. The positions are numbered 1, 2, 3, . . .
(2.3) {w ∈ {0, 1}∗ : w has length at least 3 and its third symbol is 0}.
(2.4) {, 0}.
1
Question 3: For each of the following languages, construct an NFA that accepts the lan-
guage. In all cases, the alphabet is {0, 1}. For each NFA, justify correctness.
(3.1) {w : w contains the substring 11001}.
(3.2) {w : w has length at least 2 and does not end with 10}.
(3.3) {w : w begins with 1 or ends with 0}.
Question 4: Let A be a language over the alphabet Σ = {0, 1}, and let Ā be the complement
of A. Thus, Ā is the language consisting of all binary strings that are not in A.
Assume that A is a regular language. Let M = (Q, Σ, δ, q, F ) be a nondeterministic finite
automaton (NFA) that accepts A.
Consider the NFA N = (Q, Σ, δ, q, F̄ ), where F̄ = Q \ F is the complement of F . Thus,
N is obtained from M by turning all accept states into nonaccept states, and turning all
nonaccept states into accept states.
(4.1) Is it true that the language accepted by N is equal to Ā? Justify your answer.
(4.2) Assume now that M is a deterministic finite automaton (DFA) that accepts A. Define
N as above; thus, turn all accept states into nonaccept states, and turn all nonaccept states
into accept states. Is it true that the language accepted by N is equal to Ā? Justify your
answer.
Question 5: Let A and B be two regular languages over the same alphabet Σ. Prove that
the difference of A and B, i.e., the language
A \ B = {w : w ∈ A and w 6∈ B}
is a regular language. You may use any result that was proven in class.
Question 6: Use the construction given in class to convert the following NFA to an equiv-
alent DFA.
a, b
1 2
Question 7: Use the construction given in class to convert the following NFA to an equiv-
alent DFA.
2
a
1
a
, b
b
2 a 3