Complexity
优质
小牛编辑
139浏览
2023-12-01
Complexity
There are different measurements of the speed of any given algorithm. Given an input size of N, they can be described as follows:
Name | Speed | Description |
---|---|---|
exponential time | slow | takes an amount of time proportional to a constant raised to theNth power (K^N) |
polynomial time | fast | takes an amount of time proportional toN raised to some constant power (N^K) |
linear time | faster | takes an amount of time directly proportional toN (K *N) |
logarithmic time | much faster | takes an amount of time proportional to the logarithm ofN (log(N)) |
constant time | fastest | takes a fixed amount of time, no matter how large the input is (K) |