You are on page 1of 6

SOLUTIONS: Homework Assignment 1

CSCI 2670 Introduction to Theory of Computing, Fall 2018

September 13, 2018

1. Let x and y be two positive integers. Prove (by construction) that if y − x ≥ 2,


there is an integer z between x and y, i.e., x < z < y.
Proof:
Because y − x ≥ 2, then y ≥ x + 2 or consequently, (y − 1) ≥ x + 1. That is

(y − 1) > x

On the other hand, we know


y > (y − 1)
So we can let z = (y − 1) to satisfy

x<z<y

Alternatively, we can choose z = (x + 1) with a similar proof.

1
2. CSCI 2670 class has 48 students with the average score 79 in their final exam. Prove
(by contradiction) that there is at least one student with final exam score ≥ 79.
Proof:
Assume that the claim is not correct: none of the students achieves a final exam
score ≥ 79. That is, all students’ final exam scores are ≤ 78.
So the average of students’ final exam scores is
sum 48 × 78
avg = ≤ = 78
48 48
So the average is at most 78, contradicting to the given average 79. Therefore, the
assumption was incorrect and the claim is correct.
3. Let alphabet Σ = {0, 1}. Σ0 = {}, where  is the special empty string with length
|| = 0, and, for integers k ≥ 1, Σk is defined with

Σk = {xy : x ∈ Σk−1 and y ∈ Σ}

Prove (by induction) that for every string w ∈ Σk , the length |w| = k.
Proof.
Base case: k = 0. Since Σ0 = {}, the only string in Σ0 is  that has the length || = 0.
Assumption: For k ≥ 1, any string x ∈ Σk−1 has length |x| = k − 1.
Induction: Let w ∈ Σk , by the definition of Σk , w is a concatenation xy, where
x ∈ Σk−1 and y ∈ Σ. Then by assumption, we have

|w| = |xy| = |x| + |y| = (k − 1) + 1 = k

This proves that for every string w ∈ Σk , the length |w| = k.


4. Consider the finite automaton in Figure 1. Try the following types of strings on the
FA to see if it accepts them.
abbaabbbabaa, abaabbaabba, babbbaba, bbaabbaabb
What language do you think the FA may be accepting?

Figure 1: state diagram of a finite automaton

Answer:
abbaabbbabaa (rejected)
abaabbaabba (accepted)
babbbaba (accepted)
bbaabbaabb (rejected)
The FA accepts the set of strings, each containing at least two a’s and odd number of
b’s.
5. Question 1.3 on page 83 of the textbook (both 3rd edition and 2nd edition).
The formal description of a DFA M is

M = ({q1 , q2 , q3 , q4 , q5 }, {u, d}, δ, q3 , {q3 })

where δ function is given by the following table. Draw the state diagram of this
machine.
u d
q1 q1 q2
q2 q1 q3
q3 q2 q4
q4 q3 q5
q5 q4 q5

Answer:

Figure 2: FA constructed for Question 5


6. Question 1.6 (a), (d), (j) on page 84 of the textbook (both 3rd edition and 2nd edition).
Given state diagram of DFAs recognizing the following languages. In all parts, the
alphabet is {0, 1}.
a. {w : w begins with a 1 and ends with a 0}
d. {w : w has length at least 3 and its third symbol is a 0}
j. {w : w contains at least two 0s and at most one 1}
Answer:

Figure 3: FA constructed for Question 6

You might also like