Polynomial time and exponential time

前端 未结 7 1583
误落风尘
误落风尘 2020-12-02 04:26

Could someone explain the difference between polynomial-time, non-polynomial-time, and exponential-time algorithms?

For example, if an algorithm takes O(n^2) time, t

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 04:40

    O(n^2) is polynomial time. The polynomial is f(n) = n^2. On the other hand, O(2^n) is exponential time, where the exponential function implied is f(n) = 2^n. The difference is whether the function of n places n in the base of an exponentiation, or in the exponent itself.

    Any exponential growth function will grow significantly faster (long term) than any polynomial function, so the distinction is relevant to the efficiency of an algorithm, especially for large values of n.

提交回复
热议问题