Asymptotic notation
Θ-notation
Θ(g(n)) = {f(n) : there exist positive constants c1, c2, and n0 such that 0 ≤ c1g(n) ≤ f(n) ≤ c2g(n) for all n ≥ n0}
O-notation
O(g(n)) = {f(n): there exist positive constants c and n0 such that 0 ≤ f(n) ≤ cg(n) for all n ≥ n0}.
Ω-notation
Ω(g(n)) = {f(n): there exist positive constants c and n0 such that 0 ≤ cg(n) ≤ f(n) for all n ≥ n0}.
For any two functions f(n) and g(n), we have f(n) = Θ(g(n)) if and only if f(n) = O(g(n)) and f(n) = Ω(g(n)).
T (n) = 4T (n / 2) + n
How to know the T(n) = O(f(n)), what is f(n)?
We can guess it for experience.
set f(n) = c.n^3; (n^3 means power(n,3));
prove this:
T (n) = 4T (n / 2) + n
≤ 4c ( n / 2 ) 3 + n
= ( c / 2) n 3 + n
desired – residual
= cn3 − ((c / 2)n3 − n)
≤ cn3 desired
OK , T(n) = O(n^3);
But we can't guess for any one, we can use recurrences.
T(n) = T(n/4) + T(n/2) + n^2
think this case: