Big-Theta notation
Unlike Big-O notation, which represents only upper bound of the running time for some algorithm, Big-Theta is a tight bound; both upper and lower bound. Tight bound is more precise, but also more difficult to compute.
An example
If the algorithm for the input n
takes 42n^2 + 25n + 4
operations to finish, we say that is O(n^2)
, but is also O(n^3)
and O(n^100)
. However, it is Ө(n^2)
and it is not Ө(n^3)
, Ө(n^4)
etc. Algorithm that is Ө(f(n))
is also O(f(n))
, but not vice versa!
Formal mathematical definition
Let f
and g
be two functions defined on some subset of the real numbers. We write f(x) = Ө(g(x))
as x->infinity
if and only if there are positive constants K
and L
and a real number x0
such that holds:
K|g(x)| <= f(x) <= L|g(x)|
for all x >= x0
.