• Please give details of your answer. A direct answer without explanation is not counted.
• Your answers must be in English.
• Please carefully read problem statements.
• During the exam you are not allowed to borrow others’ class notes.
• Try to work on easier questions first.
Problem 1 (15 pts)
Is (log n)3 = o(n)?
You can either use the formal definition of limit or calculate
n→∞lim
(log n)3
n (1)
However, you must show your steps of calculating (1) rather than just give your answer. We assume natural log here.
Answer
Yes.
n→∞lim
(log n)3
n = lim
n→∞
3(log n)2
n = lim
n→∞
6(log n)
n = lim
n→∞
6 n = 0
You should always be careful in writing mathematical derivations. Otherwise, we should have proved P = PN or not. Here is an example.
n→∞lim log n
n = 0
n→∞lim
(log n)3
n = 0 · lim
n→∞(log n)2 = 0 We don’t have
0 · ∞ = 0
Problem 2 (30 pts)
1. Assume
f1(n) = O(g1(n)) and f2(n) = O(g2(n)).
Is
f1(n) × f2(n) = O(g1(n) × g2(n))?
2. Assume
f1(n) = o(g1(n)) and f2(n) = o(g2(n)).
Is
f1(n) + f2(n) = o(g1(n) + g2(n))?
You need to formally prove your answer.
Answer
1. Yes. By f1(n) = O(g1(n)) and f2(n) = O(g2(n)), there exist positive c1, c2, n1, n2 such that
f1(n) ≤ c1g1(n), ∀n ≥ n1, and f2(n) ≤ c2g2(n), ∀n ≥ n2.
Take c = c1c2 and n0 = max(n1, n2), then for every integer n ≥ n0, f1(n) × f2(n) ≤ c1c2g1(n)g2(n) ≤ c(g1(n) × g2(n)).
Therefore, f1(n) × f2(n) = O(g1(n) × g2(n)).
2. Yes. By f1(n) = o(g1(n)) and f2(n) = o(g2(n)),
n→∞lim f1(n)
g1(n) = 0, and
n→∞lim f2(n) g2(n) = 0.
Then
n→∞lim
f1(n) + f2(n) g1(n) + g2(n)
= lim
n→∞
f1(n)
g1(n) + g2(n) + lim
n→∞
f2(n) g1(n) + g2(n)
≤ lim
n→∞
f1(n)
g1(n) + lim
n→∞
f2(n) g2(n)
=0 + 0 = 0
Therefore, f1(n) + f2(n) = o(g1(n) + g2(n)).
Another Solution
∀c > 0, ∃n1 such that f1(n) ≤ cg1(n), ∀n ≥ n1
∀c > 0, ∃n2 such that f2(n) ≤ cg2(n), ∀n ≥ n2
Therefore,
∀c > 0, ∃n3 = max(n1, n2) such that f1(n) + f2(n) ≤ c(g1(n) + g2(n)), ∀n ≥ n3
Common Mistakes
1.
∀c1 > 0, · · ·
∀c2 > 0, · · · Choose
c = max(c1, c2) · · · 2. You need to explain why
n→∞lim
f1(n)
f1(n) + g1(n) = 0
Problem 3 (15 pts)
If
f (n) = 2O(1), then is
f (n) = O(1)?
Give a formal proof or a counter example.
Answer
Yes. By f (n) = 2O(1), there exist positive c and n0 such that for every integer n ≥ n0 f (n) ≤ 2c1.
Take c0 = 2c, then for every integer n ≥ n0,
f (n) ≤ 2c= c01 Therefore, f (n) = O(1).
Common Mistakes
A wrong solution
O(1) = c, where c is a constant f (n) = 2O(1) = 2c
2c= O(1)
f (n) = 2O(1) = O(1) However
O(1) 6= c
when we say
f (n) = O(1) we know
f (n) ≤ a constant.
So we cannot write
O(1) = c, where c is a constant.
For example,
f (n) =
(1, if n is even 2, if n is odd then
f (n) = O(1).
But
f (n) 6= any constant.
Problem 4 (10 pts)
Give an example which is not Turing-recognizable. You need to explain why.
Answer
Denote the halting problem as H. ¯H is an example that is not Turing-recognizable. By Theorem 4.22, a language is not decidable iff either it or its complement must be not Turing-recognizable.
H is Turing-recognizable, but not decidable. Therefore, ¯H is not Turing-recognizable.
Common Mistakes
L = {w|w is an infinite string satisfying . . . } Because w is infinite, the language is not Turing-recognizable.
Note that any string in a language must be finite.
Problem 5 (15 pts)
If A and B are Turing-recognizable, is A ◦ B Turing-recognizable? Please prove it or give a counter example.
Answer
Let MA, MB be Turing machines that recognize A, B, respectively. We prove that A ◦ B is Turing-recognizable by constructing a Turing machine MAB that recognizes A ◦ B as follows.
i Assume the input string is s.
ii Non-deterministically split s into sub-strings sa and sb in all possible ways.
iii Run MA on sa. If it rejects, reject.
iv Run MB on sb. If it accepts, accept. If it rejects, reject.
Common Mistakes
1. Enumerate all possible splits of the input string. The problem is that TM may get to an
∞ loop in one split, but a later one is accepted. What you can do is to run all splits up to only i steps, where i = 0, 1, 2, · · · .
2. Run MA on w until accept, and then run B on w until remaining string. If MB accept, then accept.
This is incorrect. For example,
A = {0k1k|k ∈ N } B = {11}
w = 001111 MA will not be in accept state after it read 0011.
Problem 6 (15 pts)
If A is Turing-decidable, is A∗ Turing-decidable? Please prove it or give a counter example.
Answer
Let MA be a Turing machine that decides A. We prove that A∗ is Turing-decidable by con- structing a Turing machine MA∗ that decides A∗ as follows.
i. Assume the input string is s.
ii. Non-deterministically split s into sub-strings s1, s2, · · · in all possible ways.
iii. Run MA on s1, s2, · · · , respectively.
iv. If MA accepts each substring, then accept. Otherwise, reject.
For this problem you can instead enumerating all possibilities without worrying ∞ loops.
Problem 7 (5 or -10 pts)
In Chapter Seven (or in the lecture) we mentioned one of the greatest unsolved computer science problem. What is it?
If you correctly answer this question, you get 5 points. Otherwise, you get −10 points.
Answer
NP = P or NP 6= P
Problem 8 (5 or 25 pts)
1. (5 pts) Calculate 38, 239 × 7, 283.
2. (Bonus 20 pts) Find 33, 742, 691 = p × q, where p, q > 1 and p, q ∈ N . If you think your solution is correct, you need to let TAs know during the exam. They will give you another similar problem. If both are correct, you get the bonus 20 points.
Answer
1. 38, 239 × 7, 283 = 278, 494, 637.
2. 33, 742, 691 = 3, 779 × 8, 929