There are basically three kinds of time complexity notation:
- - Upper bound
- - Lower bound
- - Tight bound There are categorically two types of time complexity:
- Polynomial Time complexity i.e.
- Exponential Time complexity i.e. A more deep look into them:
Big-O Notation () - Upper Bound
- Definition: means that grows at most as fast as up to a constant factor, for sufficiently large .
- Mathematically: There exist positive constants and such that for all .
Example: Suppose . We claim that .
To prove this:
- For large , the term dominates the and constant terms.
- We can find constants and such that . Letβs choose and see if it works for .
for
Since and for , our choice of and works.
Thus, means that for sufficiently large , will never grow faster than some constant multiple of .
Big-Omega Notation () - Lower Bound
- Definition: means that grows at least as fast as up to a constant factor, for sufficiently large .
- Mathematically: There exist positive constants and such that for all .
Example: Suppose . We claim that .
To prove this:
- For large , the term dominates the and constant terms.
- We can find constants and such that . Letβs choose and .
for
Since , our choice of and works.
Thus, means that for sufficiently large , will always grow at least as fast as some constant multiple of .
Theta Notation () - Tight Bound
- Definition: means that grows exactly as fast as up to constant factors, for sufficiently large . It provides both an upper and lower bound.
- Mathematically: There exist positive constants , , and such that for all .
Example: Suppose . We claim that .
To prove this:
- For large , the term dominates the and constant terms.
We need to show both:
- for some .
- for some .
From the previous parts:
- with .
- with .
So, for : for
Thus, means that for sufficiently large , grows at the same rate as up to constant factors.
Summary
- Big-O (): Describes an upper bound. means grows no faster than .
- Big-Omega (): Describes a lower bound. means grows at least as fast as .
- Theta (): Describes a tight bound. means grows exactly as fast as , both in upper and lower bounds.
Example
Fibonacci Number with approach:
Fibonacci Number with approach: