CS 3343/3341 Analysis of Algorithms |
Hierarchy of Problems
|
Class | Name | Time for n=100 | Examples and Comments |
---|---|---|---|
O(1) | Constant time | 1 | Hash-table look-up. |
O(log(log(n))) | Double logarithmic |
2.7 | Interpolation search. |
O(log(n)) | Logarithmic | 6.6 | Binary search, or algorithms that halve the input size at each step. These cannot examine all of their input or else they would be at least linear. |
O(√n) | Square root | 10 | Prime testing, where you check for divisors up to √n. |
O(n) | Linear | 100 | Algorithms that go through a list of size n, such as linear search. |
O(n*log(n)) | n-log-n | 660 | High performance sorts. |
O(n2) | Quadratic | 10000 | Low-performance sorts, matrix addition, any use of doubly-nested loops. |
O(n3) | Cubic | 1000000 | Ordinary matrix multiplication, triply-nested loops. |
O(n8) | Polynomial | 1016 | Artificial problems, such as adding 8-dimensional matrices |
The class P | Polynomial- time | Not too large |
O(nk), for some fixed k. Rarely is k greater than 4 |
The class NP of problems |
Most likely P != NP | Small and large |
These are algorithms that can be verified in polynomial time |
NP-Complete problems | The
hardest in NP | Probably large |
These might also be in P, but likely not, though nobody knows. This is a large class of optimization problems that are important in many areas. |
O(2n) | Exponential | 2100 ≐ 1.267e30 | Sometimes problems that look at all subsets |
O(n!) | Factorial | 100! ≐ 9.33e157 |
Sometimes problems that look at all permutations |
O(222 ...2n) | Intractable | Unimaginable | Some problems require more time than this for any finite number of 2s, such as deciding if an extended regular expression defines the empty set. |
Undecidable problems |
Have no solution | +∞ | Also called unsolvable problems. These are problems that cannot be solved by any algorithm or machine or model of computation known to humans. |