Polynomial time and exponential time

前端 未结 7 1574
误落风尘
误落风尘 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 05:04

    Below are some common Big-O functions while analyzing algorithms.

    • O(1) - constant time
    • O(log(n)) - logarithmic time
    • O((log(n))c) - polylogarithmic time
    • O(n) - linear time
    • O(n2) - quadratic time
    • O(nc) - polynomial time
    • O(cn) - exponential time
    • O(n!) - factorial time

    (n = size of input, c = some constant)

    Here is the model graph representing Big-O complexity of some functions

    cheers :-)

    graph credits http://bigocheatsheet.com/

提交回复
热议问题