Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1 Asymptotic Notation
In this section we review the definitions for certain asymptotic notations.
O(g(n)): A function f is O(g(n)) iff there exist positive constants c, and n0 such that
0 ≤ f (n) ≤ c · g(n)
for all n ≥ n0 .
o(g(n)): A function f is o(g(n)) iff for any positive constant c, there exist a positive constant n0
such that
0 ≤ f (n) < c · g(n)
for all n > n0 .
Ω(g(n)): A function f is Ω(g(n)) iff there exist positive constants c and n0 such that
0 ≤ c · g(n) ≤ f (n)
for all n ≥ n0 .
ω(g(n)): A function f is ω(g(n)) iff for any positive constant c, there exists a positive constant
c0 such that
0 ≤ c · g(n) < f (n)
for all n ≥ n0 .
Θ(g(n)): A function f is Θ(g(n)) iff there exist positive constants c1 , c2 , and n0 such that
for all n ≥ n0 . That is, f is Θ(g(n)) iff f is both O(g(n)) and Ω(g(n)).
2 Substitution Method
The substitution method for solving analyzing recurrences is a three-step process:
1. Guess the form of the solution;
2. Verify the solution by using an inductive argument;
3. Solve for constants.
The remainder of this section illustrates the use of the substitution method.
1
Example 1
Suppose we are given the recurrence
Example 2
Suppose we are given the recurrence
Example 3
Suppose that we are given the recurrence
2
However, this is incorrect since it does not imply T (n) ≤ cn for all values of c. Instead, we should
guess T (n) ≤ cn − b for some constant b ≥ 0, giving us:
where the final inequality holds if our constant b ≥ 1. The arithmetic for the last inequality
seems a bit off. However, what is important is that the form of the conclusion matches that
of the inductive hypothesis. Now, since the result of our induction matches our hypothesis, we
can infer our desired O(n) outcome since (asymptotically) the cn term dominates the (constant)
term b, yielding our result: T (n) = O(n).
For more details regarding this and the previous example, refer to chapter 4.1 in CLRS.2
Example 4
Show that
T (n) ≤ c lg(⌈n/2⌉ − b) + 1
≤ c lg((n + 1 − 2b)/2) + 1
= c lg(n + 1 − 2b) − lg 2 + 1
= c lg(n + 1 − 2b)
≤ lg(n − Θ(1))
2 Recurrences are discussed in chapter 4 of the second edition of CLRS. At this time, I am unsure if the same