Processing math: 100%

Friday, July 15, 2016

Algorithm Analysis: How to calculate coefficients of asymptotic notation?


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:
  1. 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
  2.  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