Docsity

solutions solutions solutions solutions, Exercises of Algorithms and Programming

Toggle sidebar
bg1
EECS 336: Algorithms Problem 1.2 Solution
Note: You are not required to give formal proofs of counter examples in your solution. Instead,
sufficient explanation is enough.
(a) Claim. If f(n) = Θ(g(n)), then log(f(n)) = Θ(log(g(n))).
Analysis: The claim is False.
Proof. Consider the following counter example. Let f(n) = e(1/n)and g(n) = e.
Take N= 1 and C= 1, for all n≥N,f(n)≤C·g(n). Thus, f(n) = O(g(n)).
Take N= 1 and C= 1/e, for all n≥N,f(n)≥C·g(n). Thus, f(n) = Ω(g(n)).
Hence, f(n) = Θ(g(n)).
For any N, C ∈R+, take n= max(N, d1
Ce)≥N, we have
log(f(n)) = 1
n< C ·1 = C·log(g(n))
Thus, log(f(n)) 6= Ω(log(g(n))).
Hence, log(f(n)) 6= Θ(log(g(n))).
Therefore, the statement is false.
(b) Claim. If f(n) = Θ(g(n)), then (f(n))g(n)= Θ((g(n))f(n)).
Analysis: The claim is False.
Proof. Consider the following counter example. Let f(n) = nand g(n)=2n.
Take N= 1 and C= 1, for all n≥N,f(n)≤C·g(n). Thus, f(n) = O(g(n)).
Take N= 1 and C=1
2, for all n≥N,f(n)≥C·g(n). Thus, f(n) = Ω(g(n)).
Hence, f(n) = Θ(g(n)).
For any N, C ∈R+, take n= max(N, d2∗C+ 2e)≥N, we have
(f(n))g(n)=n2n=nn·nn> C ·2n·nn=C·(2n)n=C·(g(n))f(n)
Thus, (f(n))g(n)6=O((g(n))f(n)).
Hence, (f(n))g(n)6= Θ((g(n))f(n)).
Therefore, the statement is false.
(c) Claim. If f(n) = O(g(n)) and f(n)6= Θ(g(n)), then g(n)−f(n) = Θ(g(n)).
Analysis: The claim is False.
1
pf2

Partial preview of the text

Download solutions solutions solutions solutions and more Exercises Algorithms and Programming in PDF only on Docsity!

EECS 336: Algorithms Problem 1.2 Solution

Note: You are not required to give formal proofs of counter examples in your solution. Instead, sufficient explanation is enough. (a) Claim. If f (n) = Θ(g(n)), then log(f (n)) = Θ(log(g(n))). Analysis: The claim is False. Proof. Consider the following counter example. Let f (n) = e(1/n)^ and g(n) = e. Take N = 1 and C = 1, for all n ≥ N , f (n) ≤ C · g(n). Thus, f (n) = O(g(n)). Take N = 1 and C = 1/e, for all n ≥ N , f (n) ≥ C · g(n). Thus, f (n) = Ω(g(n)). Hence, f (n) = Θ(g(n)). For any N, C ∈ R+, take n = max(N, d (^) C^1 e) ≥ N , we have

log(f (n)) = n^1 < C · 1 = C · log(g(n))

Thus, log(f (n)) 6 = Ω(log(g(n))). Hence, log(f (n)) 6 = Θ(log(g(n))). Therefore, the statement is false.

(b) Claim. If f (n) = Θ(g(n)), then (f (n))g(n)^ = Θ((g(n))f^ (n)). Analysis: The claim is False. Proof. Consider the following counter example. Let f (n) = n and g(n) = 2n. Take N = 1 and C = 1, for all n ≥ N , f (n) ≤ C · g(n). Thus, f (n) = O(g(n)). Take N = 1 and C = 12 , for all n ≥ N , f (n) ≥ C · g(n). Thus, f (n) = Ω(g(n)). Hence, f (n) = Θ(g(n)). For any N, C ∈ R+, take n = max(N, d 2 ∗ C + 2e) ≥ N , we have (f (n))g(n)^ = n^2 n^ = nn^ · nn^ > C · 2 n^ · nn^ = C · (2n)n^ = C · (g(n))f^ (n)

Thus, (f (n))g(n)^6 = O((g(n))f^ (n)). Hence, (f (n))g(n)^6 = Θ((g(n))f^ (n)). Therefore, the statement is false. (c) Claim. If f (n) = O(g(n)) and f (n) 6 = Θ(g(n)), then g(n) − f (n) = Θ(g(n)). Analysis: The claim is False.

Proof. Consider the following counter example. Let f (n) =

n, if n is odd number 1 , if n is even number and^ g(n) =^ n^ + 1. Take N = 1 and C = 1, for all n ≥ N , f (n) ≤ C · g(n). Thus, f (n) = O(g(n)). For any N, C ∈ R+, take n = 2 · max(N, d (^) C^1 e) ≥ N (making sure n is even), we have f (n) = 1 < C · (n + 1) = C · g(n)

Thus, f (n) 6 = Θ(g(n)). For any N, C ∈ R+, take n = 2 · max(N, d (^) C^1 e) + 1 ≥ N (making sure n is odd), we have g(n) − f (n) = 1 < C · (n + 1) = C · g(n)

Thus, g(n) − f (n) 6 = Ω(g(n)). Hence, g(n) − f (n) 6 = Θ(g(n)). Therefore, the statement is false. (d) Claim. If f (n) = Ω(g(n)) and h(n) = O(g(n)), then f h^ ((nn)) = Ω(1). Analysis: The claim is True. Proof. Since f (n) = Ω(g(n)), there exists positive constants C 1 , N 1 s.t. for all n ≥ N 1 , f (n) ≥ C 1 · g(n). Since h(n) = O(g(n)), there exists positive constants C 2 , N 2 s.t. for all n ≥ N 2 , h(n) ≤ C 2 · g(n). Take N = max(N 1 , N 2 ) and C = 2 CC^12 , for all n ≥ N , f h^ ((nn)) ≥ C C^12 ··gg((nn)) ≥ C C^12 ≥ C · 1. Hence, f h^ ((nn)) = Ω(1). Therefore, the statement is true.