Big O Notation Of Exponential Functions

后端 未结 3 1192
庸人自扰
庸人自扰 2021-02-07 08:09

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 con

3条回答
  •  孤城傲影
    2021-02-07 09:02

    to campare two complexities, f(n) and g(n) you applied the limit: lim_{n->\inf} f(n)/g(n) and you have three posible answers:

    1) lim_{n->\inf} f(n)/g(n) = 0; this imply that f(n) ∈ O(g(n)) and g(n) ∉ O(f(n))

    2) lim_{n->\inf} f(n)/g(n) = +/- inf; this imply that f(n) ∉ O(g(n)) and g(n) ∈ O(f(n))

    3) lim_{n->\inf} f(n)/g(n) ∈ Real number; this imply that f(n) ∈ O(g(n)) and g(n) ∈ O(f(n))

    Then to demostrade 2^n ∈ O(3^n) you operate like this

    lim_{n->\inf} 2^n/3^n = lim_{n->\inf} (2/3)^n = 0

    And is demostrated, and we also demostraded 3^n ∉ O(2^n), and is easy to see that 2/3 < 1 this make the limit to converge to 0 then the result of the limit depends of the constants, I mean lim_{n->inf} a^n = 0 if 0 < a < 1 and lim_{n->inf} a^n = inf if a > 1;

    For a better understanding check: Introduction to Algorithms, Third Edition By Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein

    I'm professor of algorithms, I hope it helped you. Take care.

提交回复
热议问题