复杂度定义 The Definition of Complexity
The upper bound Big-O:
Definition: f(n) is in O(g(n)) if there are constants c0 and N0 such that f(n) < c0*g(n) for all n>N0. We are only interested in large n, n>N0.
(Heuristics)计算方法:删掉低阶变量(包括零阶),只保留最高阶变量,变量前的系数变为1。如15n2 + 33n + 17 is in O(n2),当然15n2 + 33n + 17 is in O(n3)也是对的,但我们通常只关心cloest bound。
Dominance Relation: n! >>2n >> n3 >> n2 >> nlogn >> n >> logn >> 1
在Dominance Relation中忽略log的底,可以通过换底公式换成相同的底,且因为系数忽略,所以底不重要。
(Arithmetic)计算方法:
(截自Comp20003, University of Melbourne)
The lower bound Big-Omega(Ω):
Definition: f(n) is Ω(g(n)) if g(n) is O(f(n))。
The tight bound / the growth rate Big-Omega(Ω):
Definition: f(n) is θ(g(n)) is f(n) is O(g(n)) and f(n) is Ω(g(n))