Processing math: 100%

算法时间复杂度

Coursera 上 Algorithms: Design and Analysis, Part 1 by Tim Roughgarden 的学习笔记。第二课,有关时间复杂度。

The Gist

时间复杂度计算概略地讲,就是“suppress constant factors and lower-order terms”

Big-Oh Notation

Formal Definition: T(n)=O(f(n)) \
if and only if exist constants c,n0 such that T(n)cf(n) \
for all n>n0

n+ 时,cf(n)T(n) 上限

Omega Notation

Formal Definition: T(n)=Ω(f(n)) \
if and only if exist constants c,n0 such that T(n)cf(n) \
for all n>n0

n+ 时,cf(n)T(n) 下限

Theta Notation

Formal Definition: T(n)=Θ(f(n)) \
if and only if T(n)=O(f(n)) and Ω(n)=O(f(n))

n+ 时,cf(n) 既能作 T(n) 下限也能作上限,