What would these statements mean if f(n)
and g(n)
are functions over natural numbers?
g(n)
is inΘ(f(n))
.
and
- An algorithm is in the complexity class
Θ(f(n))
.
What would these statements mean if f(n)
and g(n)
are functions over natural numbers?
g(n)
is in Θ(f(n))
.and
Θ(f(n))
.g(n)
is bracketed by a.f(n)
and b.f(n)
(where a<b
are two constants) for sufficiently large n
.
The running time of the algorithm is of order Θ(f(n))
.
If g(n)
is in Θ(f(n)))
then there exist real constants a
and b
greater than zero and an integer constant n0
greater than zero such that for all n > n0
, a * f(n) <= g(n) <= b * f(n)
. For instance, the function g(n) = (1 + sin(n)) * n^2
is O(n^2)
because we can choose a = 1
, b = 2
and n0 = 1
and verify the inequalities hold.
If an algorithm is in the complexity class Θ(f(n))
, then the relation G
which maps inputs of size n
to numbers of operations m
taken to process that input on some implied computer has the following properties:
min({m | G(n, m)})
and max({m | G(n, m)})
are defined.g(n) = min({m | G(n, m)})
is in Θ(f(n))
.h(n) = max({m | G(n, m)})
is in Θ(f(n))
.For a formal definition of Big Θ notation have a look at Wikipedia. A more descriptive explanation you can find here.
For an algorithm n
is the size of the input data (for example the number of elements in a list/array/…) and you will get an estimate of the „cost“ of your algorithm for increasing n
.
Cost typically means number of elementary operations (arithmetic operations, comparisons, conditions).
Simple example for an „algorithm“: accessing an arbitrary element in a container of size n
:
f(n) = 1
in your notationf(n) = n/2
(or equivalently f(n) = n
).