|
|
Take quiz & check grades |
Teta notation:
Therefore a function f(n) belongs to the set Teta(g(n)) if there exists positive constants c1,c2 such that f(n) can be "sandwiched" between c1g(n) and c2g(n) for sufficiently large values of n. Notes:
Example: Consider the function that expresses the worst-case running time of an insertion sort: T(n)= 1/2 n2 - 3 n In order to show that f(n) = n2 , we must determine c1, c2 and n0 so that: c1 n2 <= 1/2 n2 - 3 n <= c2 n2 Important: the function g(n) must be represented in a simple form. g(n) must be simpler to evaluate than f(n). Some students "discover" that f(n) could be its own g(n) with c1,c2=1 ! Remember that g(n) is a set, and we want to represent the set by the simplest form possible.
because c1 and c2 must be positive ... c2>=1/2 n>=7 c1<=1/14
|