The Asymptotic Analysis is a technique to check the efficiency from an algorithm. It doesn't take into account the computer hardware, programming language, or input.
We use asymptotic notation to express the rate of growth of an algorithm's running time for the input size n.
For sake of simplicity, we drop the insignificant terms and the constant coefficients.
- eg. instead of
- Drop factors too eg. instead of
- No need to express the speed of the algorithm in units of time (milliseconds, microseconds, etc).
Several forms of it:
Θ(n) == Θ(f(n))
When we use big-Θ notation, we're saying that we have an asymptotically tight bound on the running time. "Asymptotically" because it matters for only large values of n. "Tight bound" because we've nailed the running time to within a constant factor above and below.
Θ == Θ(1) which means that the algorithm will take the same amount of time, regardless the input size. For example, to find the smallest element in a sorted array (ASC). It would take constant time, since the smallest element must be at index 0.
Is the same thing. It's just a shorter way to write it.
Big-Theta notations order from most eficient to least.
- Θ(lg n)
- Θ(n·lg n)
- Θ(lg n)
Big-O is not the same as Big-Theta
Big-Theta expresses function growth by a simplified version of and it describes upper and lower bounds.
In contrast, Big-O considers upper bound (worst case scenario). Might be imprecise but it is useful for large values of .
Wait, what? There is also Big-Omega
OK, so which is the difference among these notations?
|Big-Θ||Big-Theta||lower and upper bounds|