Docsity

Asymptotic Notation Exercises from University of Miami by Burton J. Rosenberg - Prof. B. R, Assignments of Computer Science

Toggle sidebar
bg1
Exercises, Chapter 2
Burton J. Rosenberg
University of Miami
January 31, 2001.
Exercise 2.1-1: f(n), g(n) asymptotically nonnegative. Show max(f, g) = Θ(f+
g).
Since fand gare asy. nonneg., so is f+g. For the upper bound, by the nonneg.
of the functions:
f, g ≤f+g⇒max(f, g)≤f+g, ∀n > 0
This gives max(f, g) = O(f+g).
The lower bound is a bit trickier. The idea is that the maximum of two things
can’t be smaller than the average of those things:
1/2(f+g)≤max(f, g)∀n > 0.
This is show by contradiction. Suppose 1/2(f+g)>max(f , g). Without loss of
generality, let fbe the larger, f > g for a certain n. For this n:
f+g > 2f⇒g > f
a contradiction. Therefore, we can take no= 1 and c= 2 in the definition of Ω. 4
Exercise 2.1-2: ∀a, b ∈R, b > 0,(n+a)b= Θ(nb).
For the upper bound, let n>aso that n+a < 2n. Hence (n+a)b<(2n)b=
cunb.
For the lower bound, let nbe such that n+a > (1/2)n. Solving, this means
n > 2(−a). Hence (n+a)b>(1/2n)b=clnb.
Since (n+a)b=O(nb) and (n+a)b= Ω(nb), then (n+a)b= Θ(nb)4
Exercise 2.1-4: 2n+1 =O(2n), because 2n+1 = 2(2n).
22n6=O(2n), since we can show 22n=ω(2n):
lim
n→∞
2n/4n= (1/2)n→0.
4
Exercise 2.1-5: f= Θ(g) if and only if f=O(g) and f= Ω(g).
Suppose f= Θ(g),
f= Θ(g)⇒ ∃no, c1, c2>0 s.t. 0 ≤c1f≤g≤c2f, ∀n≥no,
Use c1, noin the definition of Ω(g) and c2, noin the definition of O(g).
1
pf3

Partial preview of the text

Download Asymptotic Notation Exercises from University of Miami by Burton J. Rosenberg - Prof. B. R and more Assignments Computer Science in PDF only on Docsity!

Exercises, Chapter 2

Burton J. Rosenberg University of Miami January 31, 2001.

Exercise 2.1-1: f (n), g(n) asymptotically nonnegative. Show max(f, g) = Θ(f + g). Since f and g are asy. nonneg., so is f + g. For the upper bound, by the nonneg. of the functions:

f, g ≤ f + g ⇒ max(f, g) ≤ f + g, ∀n > 0

This gives max(f, g) = O(f + g). The lower bound is a bit trickier. The idea is that the maximum of two things can’t be smaller than the average of those things:

1 /2(f + g) ≤ max(f, g) ∀n > 0.

This is show by contradiction. Suppose 1/2(f + g) > max(f, g). Without loss of generality, let f be the larger, f > g for a certain n. For this n:

f + g > 2 f ⇒ g > f

a contradiction. Therefore, we can take no = 1 and c = 2 in the definition of Ω. 4

Exercise 2.1-2: ∀a, b ∈ R, b > 0 , (n + a)b^ = Θ(nb). For the upper bound, let n > a so that n + a < 2 n. Hence (n + a)b^ < (2n)b^ = cunb. For the lower bound, let n be such that n + a > (1/2)n. Solving, this means n > 2(−a). Hence (n + a)b^ > (1/ 2 n)b^ = clnb. Since (n^ + a)b^ =^ O(nb) and (n^ +^ a)b^ = Ω(nb), then (n^ +^ a)b^ = Θ(nb)^4

Exercise 2.1-4: 2 n+1^ = O(2n), because 2n+1^ = 2(2n). 22 n^6 = O(2n), since we can show 2^2 n^ = ω(2n):

lim n→∞ 2 n/ 4 n^ = (1/2)n^ → 0.

Exercise 2.1-5: f = Θ(g) if and only if f = O(g) and f = Ω(g). Suppose f = Θ(g),

f = Θ(g) ⇒ ∃no, c 1 , c 2 > 0 s.t. 0 ≤ c 1 f ≤ g ≤ c 2 f, ∀n ≥ no,

Use c 1 , no in the definition of Ω(g) and c 2 , no in the definition of O(g).

Suppose f = O(g) and f = Ω(g).

f = O(g) ⇒ ∃n 1 , c 1 > 0 s.t. 0 ≤ f ≤ c 1 g, ∀n ≥ n 1

and f = Ω(g) ⇒ ∃n 2 , c 2 > 0 s.t. 0 ≤ c 2 g ≤ f, ∀n ≥ n 2

For f = Θ(g), set no = max(n 1 , n 2 ) and the two constants to c 1 and c 2. 4

Exercise 2.1-6: The best-case TBC (n) and worst-case TW C (n) run times are related to the run time T (n) by:

TBC (n) ≤ T (n) ≤ TW C (n), ∀n > 0.

TBC = Ω(g) ⇒ cBC g ≤ TBC (n), ∀n ≥ nBC

TW C = O(g) ⇒ TW C (n) ≤ cW C g, ∀n ≥ nW C

Let no = max(nBC , nW C ) and join the three inequalities.^4

Exercise 2.1-7: The set o(g) ∩ ω(g) is empty. Else, the f in the intersection satisfies, lim f /g → 0 and lim g/f → 0. 4

Exercise 2.2-1: If f (n) and g(n) are monotonically increasing, so are (f + g)(n) and f (g(n)). Suppose n > m, then by adding inequality f (n) ≥ f (m) with g(n) ≥ g(m) we have (f + g)(n) ≥ (f + g)(m), so f + g is mono. increasing. Also, n > m ⇒ g(n) ≥ g(m) ⇒ f (g(n)) ≥ f (g(m)). If also f (n), g(n) ≥ 0 for all n, multiplying inequality f (n) ≥ f (m) and g(n) ≥ g(m) gives f (n)g(n) ≥ f (m)g(m) for n > m. So the product of the function s in mono.increasing. 4

Exercise 2.2-2: T (n) = nO(1)^ if and only if T (n) = O(nk) for some k > 0.

T = nO(1)^ ⇒ ∃g ∈ O(1) s.t. T = ng(n).

But, g ∈ O(1) ⇒ ∃ k, no > 0 s.t. g(n) ≤ k, ∀n ≤ no.

By monotonicity, T = ng(n)^ ≤ nk^ for these n. Conversely, since T (n) ≥ 0 for large enough n,

T (n) = nlogn^ T^ (n)

with the special case that nlogn^0 = 0. Since T (n) = O(nk), then,

∃ c, no > 0 s.t. logn T (n) ≤ k logn n + logn c, ∀n ≥ no,