• 沒有找到結果。

CommonMistakes Answer Problem1(30pts)

N/A
N/A
Protected

Academic year: 2022

Share "CommonMistakes Answer Problem1(30pts)"

Copied!
4
0
0

加載中.... (立即查看全文)

全文

(1)

• Please give details of your calculation. 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.

• This is the final exam of Prof. Chih-Jen Lin’s Introduction to the Theory of Computation. If you take Prof. Jieh Hsiang’s class, please go to R104.

Problem 1 (30 pts)

Given an example of f and g such that (a) f , g are not polynomials

(b) f = O(g) (c) f = o(g)

Answer

If

f (x) = ex g(x) = e2x, which are not polynomials, then

x→∞lim f (x)

g(x) = lim

x→∞

ex

e2x = lim

x→∞e−x = 0.

As a result, f (x) = o (g(x)). Furthermore, we have ex < e2x for all x > 0, so we have f (x) = O(g(x)) with c = n0 = 1.

Common Mistakes

You cannot just give f (x) and g(x) without any explanation.

1

(2)

Problem 2 (30 pts)

Let

CRE = {hR, ki | R is a regular expression. L(R) contains exactly k strings where k ≥ 0 or k = ∞.}.

Is this language decidable?

Answer

Yes.

1. Given input hR, ki, then we can convert R to a DFA D, and remove all state which can not reach qaccept or can not be reached from q0.

2. If there is a loop in D:

• If k = ∞, then accept.

• If k 6= ∞, then reject.

3. Generate all (only finite many) accepted strings of D.

4. If # generated strings = k, then accept. Otherwise, reject.

Another Solution

Check “∗” in regular expression instead of converting the regular expression to a DFA, but also need to check it is neither ∗ nor any other equivalent expression.

Problem 3 (30 pts)

Define

f (n) = 2o(g(n)) if

n→∞lim

log2f (n) g(n) = 0.

Prove or disprove the following statements:

(a)

f (n) = 2o(g(n)) is equivalent to

f (n) = o(2g(n)).

2

(3)

(b)

f (n) = 2O(g(n)) is equivalent to

f (n) = O(2g(n)).

Answer

(a) No. If

f (x) = 2x g(x) = 2x, then

x→∞lim f (x)

2g(x) = lim

x→∞

2x

22x = lim

x→∞2−x= 0, which means f (x) = o 2g(x).

However,

x→∞lim

log2f (x)

g(x) = lim

x→∞

x 2x = 1

2, so f (x) 6= 2o(g(x)).

(b) No. If

f (x) = 22x g(x) = x, then

2x = O(x), which means f (x) = 22x = 2O(x) = 2O(g(x)).

However, for all positive integers n0 and c, there exists a n = max (n0 + 1, log2(c)) > n0, such that f (x) = 22x ≥ 2x× 2log2(c) ≥ c2x = c2g(x) (because 2x is strictly increasing). So f (x) 6= O 2g(x).

Common Mistakes

1. To show that two things are not equivalent, you need to give “examples.”

2. We of course assume f (n) and g(n) are positive functions.

3

(4)

Problem 4 (10 or 40 pts)

(a) (10 pts) Calculate 2, 011 × 530, 528

(b) (Bonus 30 pts) Find 55, 983, 881 = p × q, where p, q > 1 and p, q ∈ N.

Answer

(a) 2, 011 × 530, 528 = 1, 066, 891, 808.

(b) 55, 983, 881 = 5, 281 × 10, 601.

4

參考文獻

相關文件

Multiple Choice Questions — Use an HB pencil to blacken the circle next to the correct answer... Please do not write in

Multiple Choice Questions — Blacken the circle next to the correct answer with an HB pencil... Please do not write in

Teachers may provide students with examples with contexts to enable them to discover the associative property of multiplication of three numbers, and design some concrete examples

After students have mastered the skills of performing addition, subtraction and mixed operations of addition and subtraction of fractions with different

Multiple Choice Questions –– Blacken the circle next to the correct answer with an HB pencil2. There are 3 parts in this

Multiple Choice Questions –– Blacken the circle next to the correct answer with an HB pencil2. There are 2 parts in this

Multiple Choice Questions –– Blacken the circle next to the correct answer with an HB pencil3. There are 2 parts in this

Multiple Choice Questions — Use an HB pencil to blacken the circle next to the correct answer.. There are 10 pages in this