written 8.4 years ago by
teamques10
★ 68k
|
•
modified 8.0 years ago
|
θ- Notation (Figure 3 (a)):
- The theta notation bounds a function from above and below, so it defines exact asymptotic behavior.
- A simple way to get Theta notation of an expression is to drop low order terms and ignore leading constants.
- For example, consider the following expression.
$3n^3 + 6n^2 + 6000 = θ(n^3)$
- Formal definition:
Let f and g be two functions defined on some subset of the real numbers then
f(n) = θ (g(n)) as n→ infinity
If there are exist positive constants ‘$n_o$’ and ‘$c_1$’ and ‘$c_2$’such that to the right of ‘$n_o$’, the value of f (n) always lies between $c_1g(n)$ and $c_2g(n)$ inclusive.
O- Notation (Figure 3 (b)):
- The Big O notation defines an upper bound of an algorithm.
- It bounds a function only from above.
- For example, consider the case of Insertion Sort. It takes linear time in best case and quadratic time in worst case.
- The time complexity of Insertion sort is $O (n^2)$. Note that $O(n^2)$ also covers linear time.
- Formal definition:
Let f and g be two functions defined on some subset of the real numbers then
f(n) = O (g(n)) as n→ infinity
If there are positive constants ‘no’ and ‘c’ such that to the right of ‘no’, the value of
f (n)always lies on or below cg(n).
Ω-Notation (Figure 3 (c)):
- The Omega notation defines a lower bound of an algorithm.
- It bounds a function only from below.
- For example, consider the case of Insertion Sort. The time complexity of Insertion sort is Ω (n).
- But it is not very useful information about insertion sort, as we use worst case and sometimes in average case.
- Formal definition:
Let f and g be two functions defined on some subset of the real numbers then
f(n) = Ω(g(n)) as n→ infinity
If there are positive constants ‘$n_o$’ and ‘$c$’ such that to the right of ‘no’, the value of
f (n)always lies on or above cg(n).