Big O
Calculating the complexity of an algorithm.
Some algorithms scale well with growing inputs.
Big O
O
, not zero 0
Omega Notation
(Ω
).
Theta Notation
(Θ
)
Big O
From the most efficient to least efficient:
n
= number of inputs.
constant time O(1) logarithmic O(log n) linear O(n) Linearithmic O(n log n) Quadratic O(n^2) Exponential O(2^n) Factorial O(n!)
Constant
is always the same amount of time regardless of input size.
1
input or 10,000,000
input take same timeLinear
is scales linearly with the input size.
1
input takes one second, 600
inputs take 10 minutes
Quadratic
scales as exponent of 2
4
items take 16 seconds
; 10
items take 100 seconds
.