zoukankan      html  css  js  c++  java
  • ALG 2-2: Asymptotic Order of Growth (渐进分析)

    1. Asymptotic Order of Growth

    • Upper bounds. T(n) is O(f(n)) if there exist constants c > 0 and n0 ≥ 0 such that for all n ≥ n0 we have T(n) ≤c · f(n).
    • 上界: T(n)为O(f(n)),如果存在常数c > 0 和 n0 ≥ 0,使得对所有 n ≥ n0 有 T(n) ≤ c·f(n)
    • Lower bounds. T(n) is Ω(f(n)) if there exist constants c > 0 and n0 ≥ 0 such that for all n ≥n0 we have T(n) ≥c · f(n).
    • 下界: T(n)为Ω(f(n)),如果存在常数c > 0 和 n0 ≥ 0,使得对所有 n ≥ n0 有 T(n) ≥ c·f(n)
    • Tight bounds. T(n) is Θ(f(n)) if T(n) is both O(f(n)) and Ω(f(n)).

    Ex: T(n) = 32n^2+ 17n + 32.

    • T(n) is O(n^2), O(n^3), Ω(n^2), Ω(n), and Θ(n^2) .
    • T(n) is not O(n), Ω(n^3), Θ(n), or Θ(n^3).

    2. Properties (性质)

    Transitivity. (交换性)

    • If f = O(g) and g = O(h) then f = O(h).
    • If f = Ω(g) and g = Ω(h) then f = Ω(h).
    • If f = Θ(g) and g = Θ(h) then f = Θ(h).

    Additivity. (相加性)

    • If f = O(h) and g = O(h) then f + g = O(h).
    • If f = Ω(h) and g = Ω(h) then f + g = Ω(h).
    • If f = Θ(h) and g = O(h) then f + g = Θ(h).

    3. Asymptotic Bounds for Some Common Functions (一些常见函数的渐近界)

    1. Polynomials(多项式). a_0+ a_1*n + … + a_d*n^d is Θ(n^d) if a_d> 0.
      • Polynomial time. Running time is O(n^d) for some constant d independent of the input size n. (与输入大小n无关, 运行时间恒为O(n^d) )
    2. Logarithms(对数). O(loga n) = O(logb n) for any constants a, b > 0.
      •  Logarithms. For every x > 0, log n = O(n^x). l(log grows slower than every polynomial )

        3. Exponentials(指数). For every r > 1 and every d > 0, n^d= O(r^n). (every exponential grows faster than every polynomial)

  • 相关阅读:
    BestCoder Round #65 hdu5590(水题)
    codeforces Ebony and Ivory(水题)
    codeforces 630B Moore's Law
    BestCoder Round #69 (div.2)(hdu5611)
    BestCoder Round #73 (div.2)(hdu 5630)
    codeforces 630A Again Twenty Five!
    codeforces 630C Lucky Numbers
    codeforces 630D Hexagons!
    Codeforces243C-Colorado Potato Beetle(离散化+bfs)
    hdu4453-Looploop(伸展树)
  • 原文地址:https://www.cnblogs.com/JasperZhao/p/13972197.html
Copyright © 2011-2022 走看看