Академический Документы
Профессиональный Документы
Культура Документы
f(n), for n n
1
. Equivalently, f(n) (1/c
)g(n), for n n
1
. This shows that
f(n) = (g(n)), proving the if part. Thus both parts of the lemma are proved.
Property 2. f(n) = (g(n)) if and only if f(n) = O(g(n)) and g(n) = O(f(n)).
Proof. Suppose f(n) = (g(n)). Then there exist positive constants c
1
and c
2
and positive integer
n
0
such that c
1
g(n) f(n) c
2
g(n), for all n n
0
. By the rst part of the inequality, c
1
g(n)
f(n), for n n
0
, or, that, g(n) (1/c)f(n). Hence, g(n) = O(g(n)). By the second inequality,
f(n) c
2
g(n), for n n
0
, we have, f(n) = O(g(n)). This proves the only if part.
Conversely, suppose f(n) = O(g(n)) and g(n) = O(f(n)). From the former we obtain that there
exists a positive constant c
1
and a positive integer n
0
such that for n > n
0
, f(n) c
1
g(n).
Since, g(n) = O(f(n)), there exist c
2
and n
1
such that for n > n
1
, g(n) c
2
f(n), or, that
(1/c
2
)g(n) f(n). Hence, for n > max(n
0
, n
1
), we have,
(1/c
2
)g(n) f(n) c
1
g(n)
or that f(n) = (g(n)). This proves the if part of the statement of the lemma.
Example 2. As an example, consider the function
n
2
2
3n. Intuitively, it appears to be (n
2
). To
see this, we have to show that there exist constants c
1
and c
2
, and a value n
0
such that
c
1
n
2
n
2
2
3n c
2
n
2
holds for n > n
0
. Dividing by n
2
yields
c
1
1
2
3
n
c
2
.
For n 12 = n
0
, we can choose c
1
= 1/4 to satisfy the left-inequality. The right-inequality is
satised by choosing c
2
= 1/2. Hence,
n
2
2
3n = (n
2
). Note that other choices of the constants
c
1
, c
2
and n
0
exist as well (for e.g., n
0
= 10, c
1
= 0.2 and c
2
= 1/2; or, n
0
= 100, c
1
= 0.47, c
2
= 0.5
etc.). However, to show that f(n) = (g(n)), any one choice of the constants suces.
3
Example 3. As another example, we can use the denition to show that 10n (n
2
). Suppose
10n = (n
2
). Then, there exists positive constants c
1
, c
2
and n
0
such that
c
1
n
2
10n c
2
n
2
Dividing by n
2
, we have,
c
1
10
n
c
2
However, as n , 10/n 0, and there cannot be any positive constant c
1
satisfying c
1
10/n
for all n > n
0
, for any n
0
.
Example 4. The above examples suggest that a quadratic function f(n) = an
2
+ bn + c, with
a > 0, is (n
2
). Informally, we note that the asymptotic growth is quadratic (ignoring the lower
order terms and by dropping the constant a, we get (n
2
). This may be justied formally.
Let the upper constant c
2
= a + |b| + |c|, so that c
2
n
2
an
2
+ bn + c for all n 1. Also,
(an
2
+bn+c) = n
2
(a+b/n+c/n
2
). For n n
0
= max(4|b|/a, 2
|c|/
n
i=1
i
a
, where a > 0 is a constant.
4. Is 2
n+1
= O(2
n
)? Is 2
2n
= O(2
n
)?
5. Show that o(g(n)) (g(n)) is the empty set.
5