O: Difference between revisions

969 bytes added ,  3 years ago
m
added an ;Also see (for a Wiki reference).
(Algoritmic complexity notation)
 
m (added an ;Also see (for a Wiki reference).)
 
(5 intermediate revisions by 3 users not shown)
Line 1:
[[Category:Encyclopedia]]
[[Category:Encyclopedia]]'''Complexity'''. In computer science the notation O(P(n)) is used to denote asymptotic behavior of an algorithm, usually its complexity in terms of execution time or memory consumption. Here ''P'' is an algebraic function of ''n'', usually polynomial or logarithmic. ''n'' describes the size of the problem. The meaning of O(P(n)) is that the complexity grows with n as P(n) does.
 
;Complexity:
[[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.
 
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 complexity classes listed from 'slowest' to 'fastest' (that is, slower algorithms have Big-O's near the top):
:* &nbsp; O(e<sup>n</sup>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exponential
:* &nbsp; O(n<sup>k</sup>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for some fixed ''k'' ('polynomial')
:* &nbsp; O(n<sup>3</sup>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cubic
:* &nbsp; O(n<sup>2</sup>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; quadratic
:* &nbsp; O(n*log(n)) &nbsp; &nbsp; &nbsp; fastest possible time for a [[:Category:Sorting Algorithms|comparison sort]]
:* &nbsp; O(n) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; linear
:* &nbsp; O(log(n)) &nbsp; &nbsp; &nbsp; &nbsp; logarithmic
:* &nbsp; O(1) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; constant
 
 
 
;Also see:
See* also&nbsp; Wikipedia: &nbsp; [[httphttps://en.wikipedia.org/wiki/Big_O_notation Big O notation]].