Complexity of Algorithms
Table of contents
Commonly used complexity classes
: constant : logarithmic : square root : linear : loglinear : polynomial : exponential : factorial
Commonly used definitions in complexity analysis
Properties of logarithms
Arithmetic series
Geometric series
Harmonic series
Faulhaber’s formula
Special case of power sum.
Asymptotic notation
Big-O notation
Big-O
Not necessarily tight.
For some function
- Transitivity:
- Reflexivity:
Big-Omega notation
Big-Omega
Not necessarily tight.
For some function
- Transitivity
- Reflexivity
- Transpose symmetry:
Big-Theta notation
Big-Theta
For some function
- Transitivity
- Reflexivity
- Symmetry:
Master theorem
Divide-and-conquer recurrence relations
For recursive, divide-and-conquer algorithms, the master theorem can be used to determine the asymptotic complexity.
Simple form
If the algorithm has the following recurrence relation,
where
- If
(dominated by the work at root), - If
(work is evenly distributed in each layer), - If
(dominated by the work at leaves),
Advanced form
Advanced form of Master theorem
If the algorithm has the following recurrence relation,
where
- If
, - If
,- If
, - If
, - If
,
- If
- If
,- If
, - If
,
- If
Decreasing recurrence relations
If the algorithm has the following recurrence relation,
where
- If
(dominated by the work at root), - If
(work is evenly distributed in each layer), - If
(dominated by the work at leaves),
Amortized analysis
Amortized analysis is a method for analyzing a sequence of operations. It is often used to show that a sequence of operations is efficient.
Even if a single operation is expensive, the amortized cost of each operation can be small if the expensive operation is performed rarely.
Amortized analysis is used when the worst-case asymptotic analysis over a sequence of operations is unfairly pessimistic.