A way of comparing different algorithms. Algorithms’ time to run is hard to measure exactly and hard to compare with fairness. And also there are too many uncontrollable variables in measuring the actual time. Because of that, the algorithms are analyzed asymptotically: a way of measuring the performance of an algorithm without depending on hardware.
Cons of complexity analysis
Section titled “Cons of complexity analysis”- The algorithm might not reach the limit after which the asymptotic behaviour
is seen
Different algorithms can be used for different input ranges - The input density and input size might not be uniform
Usually assumed to be uniform and is considered good enough. Experimentation is required for more precise approximation. - Not all functions (such as periodic, oscillating functions) can be compared
Asymptotic notation
Section titled “Asymptotic notation”A method used to categorize functions or to calculate upper/lower bounds with respect to the growth rate of functions. In this context, total number of steps followed by a specific algorithm is expressed in terms of its input size , then asymptotic analysis can be done.
Time complexity
Section titled “Time complexity”Analysis of how the running time of the algorithm grows with various input sizes.
Instead of measuring the running time of the algorithm for specific inputs, how the running time increases with the increasing input size.
Space complexity
Section titled “Space complexity”Analysis of additional space required for an algorithm to run.
Asymptotic functions
Section titled “Asymptotic functions”There are more than one asymptotic notations. All these are sets of functions.
Suppose are 2 functions of .
iff :
An asymptotic upper bound.
Big-Omega
Section titled “Big-Omega”iff :
An asymptotic lower bound.
Big-Theta
Section titled “Big-Theta”iff :
An asymptotic equivalence. A tight characterization unlike Big-O or Big-Omega.
Soft-O
Section titled “Soft-O”Denoted by . Similar to Big-O but the logarithmic terms are removed in the analysis. Not used as much as the other three.
Little-o
Section titled “Little-o”iff :
Strict upper bound characterization.
Implies Big-O.
Implies “not Big-Theta”.
Little-omega
Section titled “Little-omega”iff :
Strict lower bound characterization.
Implies Big-Omega.
Implies “not Big-Theta”.
Limit definitions
Section titled “Limit definitions”| Name | Definition |
|---|---|
| Little-o | |
| Big-O | |
| Big-Theta | |
| Little-omega | |
| Big-Omega |
Properties of asymptotic functions
Section titled “Properties of asymptotic functions”Transitivity
Section titled “Transitivity”If and then . Applies to all 5 functions.
Reflexivity
Section titled “Reflexivity”Transpose
Section titled “Transpose”Relations between asymptotic notations
Section titled “Relations between asymptotic notations”Big-O & Big-Omega
Section titled “Big-O & Big-Omega”Big-Theta => Big-O & Big-Omega
Section titled “Big-Theta => Big-O & Big-Omega”Big-Theta equivalence
Section titled “Big-Theta equivalence”Real life timing
Section titled “Real life timing”Wall-clock time
Section titled “Wall-clock time”Time elapsed from start of the process to “now” when measured by a stopwatch.
User-cpu time
Section titled “User-cpu time”Time spent in user code.
System-cpu time
Section titled “System-cpu time”Time spent in kernel code.