An algorithm with running time f(n) is said to be \theta(g(n)) if the following holds:
c_1g(n) \leq f(n) \leq c_2g(n) for all n>n_0 and some value of c_1 and c_2.
For example, f(n)=\frac{n^2}{2}-3n is \theta(n^n).
To prove this, we need to find at least one set of values for n_0, c_1 and c_2 that satisfies above inequality. Below is a simple procedure to do that:
- To calculate c_1, obtain a value of n for which f(n) is positive and solve left side inequality with that value of n.
- n_0=7 and c_1\leq1/14
- To calculate c_2, just put n=1 and solve the right side inequality.
- n_0=1 and c_2=1/2
The basic idea is to make sure that c_1 and c_2 are positive.
No comments:
Post a Comment