Professional Documents
Culture Documents
Assignment #1 Solution:
𝑛2
a) − 3n = Θ(𝑛2 )
2
Solution:
𝑛2
𝐶1 g(n) ≤ − 3n ≤ 𝐶2 g(n)
2
.. . g (n) = 𝑛2 given:
𝑛2
𝐶1 (𝑛2 ) ≤ − 3n ≤ 𝐶2 (𝑛2 )
2
Let n = 7 𝑛0 ≥ 6
1 3
𝐶1 ≤ ‾7
2
7−6 1
𝐶1 ≤ = 14
14
1
𝐶1 ≤ 14
𝑛2
− 3n ≤ 𝐶2 (𝑛2 )
2
As we know
𝑛2 𝑛2
− 3n ≤
2 2
𝑛2 1
− 3n ≤ (𝑛2 )
2 2
1
𝐶2 = 2
Solution:
𝐶1 = 3
For 𝑛𝑜 :
6𝑛2 + 6000 ˃ 0
6𝑛2 ˃ - 6000
For 𝑛0 :
6𝑛2 ≤ 6𝑛3
𝑛0 ≥ 1
2. 6𝑛3 ≠Θ(𝑛2 )
Solution:
f (x) = 6𝑛3
g (x) = 𝑛2
𝑓(𝑥)
lim =C
𝑛→∞ 𝑔(𝑥)
6𝑛3
lim
𝑛→∞ 𝑛2
lim 6 n
𝑛→∞
= 6 (∞)
= ∞
𝑛3 ≠ Θ (𝑛2 ) Proved
3. Suppose program A takes 2n/1000 units of time and program B takes 1000𝑛2 units. For
Solution:
2𝑛
A -> 1000
B -> 1000𝑛2
2𝑛 < 1000000𝑛2
1 < 500000n
1 1
< 500000 or n > 500000 or n > 0.00002 for all values of n
𝑛
4. Following are some big-oh relationships. For each, give witnesses n0 and c that can be
a. n2 is O(.001n3)
Solution:
𝑛2 ≤ .001 𝑛3 C=.001
For no:
𝑛2 ≤ .001 𝑛3
𝑛2
≤ .001
𝑛3
1
≤ .001
𝑛
1
𝑛0 ≥ .001 ->Reciprocal
𝑛0 ≥ 1000
Solution:
≤ 38n4 + 77
≤ 39n4 − 𝑛4 + 77
≤ 39n4 −( 𝑛4 − 77)
≤ 39n4
.. . 𝑛4 − 77 ≥ 0
𝑛4 ≥ 77
𝑛 ≥ 2.96
C =39
no = 2.96
c. 2n+10 is O(2n)
Solution:
2n+10 ≤ C (2n)
d. n10 is O(3n)
Solution:
n10 ≤ C (3n)
For C:
Apply 𝑙𝑜𝑔𝑛 on both sides
10 ≤ 𝑙𝑜𝑔𝑛 𝐶 + n 𝑙𝑜𝑔𝑛 3
10 ≤ 𝑙𝑜𝑔3 𝐶 + 3 n=3
7 ≤ 𝑙𝑜𝑔3 𝐶
𝑙𝑜𝑔3−1 (7) ≤ C
2187 ≤ C
C ≥ 2187
e. 𝑙𝑜𝑔2 𝑛 is O(√n)
Solution:
𝑙𝑜𝑔2 𝑛 ≤ C √n
Let no = 2
1 ≤ C√2
1
C ≥ √2
5. Suppose that f(n) is O(g(n)) and g(n) is O(f(n)). What can you say about f(n) and g(n)? Is
it necessarily true that f(n) = g(n)? Does the limit f(n)/g(n) as n goes to infinity
necessarily exist?
Solution:
f(n) ≤ Cg(n)
and
g(n) ≤ C f(n)
.. . f (n) = g (n)