zoukankan      html  css  js  c++  java
  • Review master theorem

    For recurrent relation with the following format:

    (T(n) = a T(frac{n}{b}) + f(n))

    Let (c=log_b a) be the critical exponent. Master theorem compares the relative growth of (f(n)) and (n^{c}), specifically:

    • if (exists epsilon gt 0), (f(n) in O(n^{c-epsilon})), which means (f(n)) is upper bounded by (n^c), then (T(n) in Theta(n^c));
    • if (exists k geq 0, f(n) in Theta(n^c log^{k}n)), which means (f(n)) grows in the same order as (n^c log^k n), then, (f(n) in Theta(n^c log^{k+1}n))
    • if (exists epsilon gt 0), (f(n) in Omega(n^{c+epsilon})) and (exists c<1, a f(frac{n}{b}) < cf(n)) for all sufficiently large (n), then (T(n) in Theta(f(n)))

    Some examples:

    1. (T(n) = 3T(n/2) + n^2)
    2. (T(n) = 4T(n/2) + n^2)
    3. (T(n) = 10T(n/3) + n^2)
    4. (T(n) = 2T(n-1) + 1) Tower of Hanio
    5. (T(n) = T(sqrt{n}) + 1)
    6. (T(n) = 2T(n/2) + nlog n)

    Relation 4) and 5) cannot be solved by master theorem, but could be solved by iterated substitution.

    This is a test of markdown

    (T(n) = O(n) + frac{1}{n} sum_{k=1}^{n}T(n-k))

    iterated substitution:

  • 相关阅读:
    450. 删除二叉搜索树中的节点
    958. 二叉树的完全性检验
    5211. 概率最大的路径(197)
    5447. 石子游戏 IV
    174. 地下城游戏
    Codeforces Round #622 (Div. 2).C2
    Codeforces Round #624 (Div. 3) F. Moving Points 题解
    竞赛头
    离散化
    线段树
  • 原文地址:https://www.cnblogs.com/gaoqichao/p/9121467.html
Copyright © 2011-2022 走看看