Python 算法类型详细操作教程
最佳情况-程序执行所需的最短时间。
平均情况-程序执行所需的平均时间。
最坏的情况-程序执行所需的最长时间。
Ο表示法
Ω 表示法
θ 表示法
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-15
Ο( f(n)) = { g(n) : there exists c > 0 and n 0 such that f(n) ≤ c. g(n) for all n > n 0. }
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-15
Ω( f(n)) ≥ { g(n) : there exists c > 0 and n 0 such that g(n) ≤ c. f(n) for all n > n 0. }
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-15
θ( f(n)) = { g(n) if and only if g(n) = Ο( f(n)) and g(n) = Ω( f(n)) for all n > n 0. }
constant | − | Ο(1) |
logarithmic | − | Ο(log n) |
linear | − | Ο(n) |
n log n | − | Ο(n log n) |
quadratic | − | Ο(n2) |
cubic | − | Ο(n3) |
polynomial | − | nΟ(1) |
exponential | − | 2Ο(n) |