Can anybody explain which one of them has highest asymptotic complexity and why,
10000000n vs 1.000001^n vs n^2
Can anybody explain which one of them has highest asymptotic complexity and why,
10000000n vs 1.000001^n vs n^2
You can use standard domination rules from asymptotic analysis.
Domination rules tell you that when n -> +Inf
, n = o(n^2)
. (Note the difference between the notations O(.)
and o(.)
, the latter meaning f(n) = o(g(n))
iff there exists a sequence e(n)
which converges to 0
as n -> +Inf
such that f(n) = e(n)g(n)
. With f(n) = n
, g(n) = n^2
, you can see that f(n)/g(n) = 1/n -> 0
as n -> +Inf
.)
Furthermore, you know that for any integer k
and real x > 1
, we have n^k/x^n -> 0
as n -> +Inf
. x^n
(exponential) complexity dominates n^k
(polynomial) complexity.
Therefore, in order of increasing complexity, you have:
n << n^2 << 1.000001^n
Note:10000000n
could be written O(n)
with the loose written conventions used for asymptotic analysis in computer science. Recall that the complexity C(n)
of an algorithm is O(n)
(C(n) = O(n)
) if and only if (iff) there exists an integer p >= 0
and K >= 0
such that for all n >= p
the relation |C(n)| <= K.n
holds.
When calculating asymptotic time complexity, you need to ignore all coefficients of n
and just focus on its exponent.
The higher the exponent, the higher the time complexity.
In this case
We ignore the coefficients of n
, leaving n^2, x^n and n
.
However, we ignore the second one as it has an exponent of n
. As n^2
is higher than n
, the answer to your question is n^2
.