Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Big O Notation Of Exponential Functions

Tags:

algorithm

I have noticed that big-O of 1000n or 10n is the same thing as O(n), but big-O of 2^n and 3^n are different: O(2^n) and O(3^n), what I don't get is why can't we ignore the constants in this case (2 or 3) and whether there is any mathematical proof justifying this?

like image 697
fYre Avatar asked Sep 29 '13 18:09

fYre


People also ask

What is Big O of exponential function?

O(C^n) — Exponential: The number of steps it takes to accomplish a task is a constant to the n power (pretty large number).

What is exponential time complexity in terms of Big O notation?

Exponential: O(2^N) For instance, with a function whose step-time doubles with each subsequent step, it is said to have a complexity of O(2^N). A function whose step-time triples with each iteration is said to have a complexity of O(3^N) and so on.

What is the formula of Big O notation?

Formal Definition: f(n) = O(g(n)) means there are positive constants c and k, such that 0 ≤ f(n) ≤ cg(n) for all n ≥ k. The values of c and k must be fixed for the function f and must not depend on n. Also known as O, asymptotic upper bound.


2 Answers

Because there is no constant value of k that satisfies the inequality 3^n <= k * 2^n for arbitrarily large n. Thus f(n) = 3^n is not a member of O(2^n).

See http://en.wikipedia.org/wiki/Big_O_notation#Family_of_Bachmann.E2.80.93Landau_notations.

like image 138
Oliver Charlesworth Avatar answered Sep 28 '22 22:09

Oliver Charlesworth


Eventhough for the original asker this might not be of use anymore,
I think it can be approached in an easier way.

Basic defenition of O-notation: iff f(g) would be in O(g(n)),
then there exist a rational number c, for which it holds that f(g) = c * g(n), for n >= n0
(n0 being a number that you pick yourself)

Let's try to apply this for 3^n in O(2^n)
3^n = 2^n * c
3^n = 2^n * (3^n / 2^n)
3^n = 2^n * (3/2)^n
3^n = 2^n * 1.5^n

this means that c = 1.5^n which is not a rational number, but an exponential function on its own.

On the other hand, following the same for 3^n in O(2^n), we would get 2^n <= 3^n * (2/3)^n

This might seem like a conflict, until you realise that 0.75^n < 1 for all n > 0, which means that if you take any c > 1, it will be larger than 0.67^n from n = 0

like image 44
Work of Artiz Avatar answered Sep 28 '22 21:09

Work of Artiz