Algorithms can be understood and studied in a language- and machine-independent manner. We want to compare the efficiency of algorithms without implementing them. Two tools for this are the RAM model of computation and asymptotic analysis of worst-case complexity (big Oh)
- each simple operation (+, *, -, =, if, call) takes exactly one time step
- loops and subroutines are the composition of many single-step operations (number of time steps depend on the number of iterations or nature of subroutine)
- each memory access takes exactly one time step
To analyze the complexity of an algorithm we must know how it works over all instances.
-
The worst-case complexity of the algorithm is the function defined by the maximum number of steps taken in any instance of size n. This is generally the mopst important.
-
The best-case complexity of the algorithm is the function defined by the minimum number of steps taken in any instance of size n.
-
The average-case complexity of the algorithm, which is the function defined by the average number of steps over all instances of size n.
These time complexities define a numerical function, representing time versus problem size. These are tipically so complex that we need to simplify them.