O: Difference between revisions

154 bytes added ,  15 years ago
Big-O is upper limit; names for typical complexity classes; some other minor modifications
(Added ordered list of notations)
(Big-O is upper limit; names for typical complexity classes; some other minor modifications)
Line 1:
[[Category:Encyclopedia]]'''Complexity'''. In computer science the notation O(Pf(n)) is used to denote an upper limit of the asymptotic behavior of an algorithm, usually its complexity in terms of execution time or memory consumption (space). Here ''Pf'' is an algebraica function of ''n'', usuallyoften a polynomialpower or logarithmiclogarithm. ''n'' describes the size of the problem. The meaning of O(Pf(n)) is that the complexity grows with n at most as Pf(n) does.
 
The notation can also be used to describe a computational problem. In that case it characterizes the problem's complexity through the best known algorithm that solves it.
Line 5:
Examples: searching in an unordered container of ''n'' elements has the complexity of O(''n''). Binary search in an ordered container with random element access is O(log ''n''). The term random access actually means that the complexity of access is constant, i.e. O(1).
 
Here are some typical Big-O'scomplexity classes listed from 'slowest' to 'fastest' (that is, slower algorithms have Big-O's near the top):
*O(ne<sup>n</sup>) ('exponential')
*O(n<sup>k</sup>) for some fixed ''k'' ('polynomial')
*O(n!)
*O(kn<sup>n3</sup>) ('cubic')
*O(n<sup>32</sup>) ('quadratic')
*O(n<sup>2</sup>)
*O(n*log(n)) (fastest possible time for a comparison sort)
*O(n) ('linear')
*O(log(n)) ('logarithmic')
*O(1) ('constant')
 
See also [http://en.wikipedia.org/wiki/Big_O_notation Big O notation]
Anonymous user