O(g(n)) = {f(n): there are constants c>0,n0>0, such that f(n)< cg(n) for all n>

=
n0}
Macro convention:
A set in a formula represents an anonymous function in that set.
ex: f(n)=n^3 + O(n^3)
Theta(g(n)) = O(g(n)) union Omega(g(n))
strict notation: omega-> lower bound, o-> upper bound
Solving recurrences
tech1: substitution method
step1. Guess the form of the solution
step2. Verify by induction
step3. Solve for consts
ex: T(n)=4T(n/2)+n
pf:
Assume T(k)<=ck^2, for k<n
T(n)=4c(n/2)^2+n
=cn^2-(-n), oh no -n<0, this pf doesn't complete
:( , but intuitively T(n)=O(n^2)
so we have to change the guess
Assume T(k)<=c1k^2-c2k for k<n
T(n)=4(c1(n/2)^2+c2(n/2))+n
=c1n^2+(1-2c2)n, assign c2>=1 ##
tech2: recursion-tree (recommended)
ex: T(n)=T(n/4)+T(n/2)+n^2
span it!
n^2
1*n^2 <= n^2
(n/4)^2

/ \
(n/2)^2

5/16*n^2

<= n^2
/
\
/
(n/16)^2 (n/8)^2 (n/8)^2 (n/4)^2
/\...
Theta(1) ...
Theta(1)

\
25/256*n^2 <= n^2
... (5/16)^k*n^2

<= n^2
sum up : T(n) = O(n^2)
master tech: applies to recurrence, of the form T(n)=aT(n/b)+f(n), where a>=1, b
>1, f(n) is asynptotically positive.
plus, compare f(n) with n^log_b(a)
case1. f(n)=O(n^(log_b(a)-epsilon)), for some epsilon>0
T(n)=Theta(n^log_b(a))
case2. f(n)=O(n^(log_b(a)(log n)^k)), for some k>=0
T(n)=Theta(n^(log_b(a)(log n)^(k+1)))
case3. f(n)=Omega(n^(log_b(a)+epsilon)), for some epsilon>0 & a*f(n/b)<=
(1-epsilon')*f(n), for some epsilon'>0
T(n)=Theta(f(n))
pf sketch/intuition
h=log_b(n)
a^h=a^log_b(n)=n^log_b(a)

Sign up to vote on this title
UsefulNot useful