The notes of Algorithms ---- Solving Recurrences
来源:互联网 发布:关于网络的英语作文 编辑:程序博客网 时间:2024/06/04 17:48
There are three solutions to solve the recurrences.
Substitution method:
1. Guess the form of the solution
2. Verify by induction
3. Slove for consts
Recursion-tree method:
1. Count the height
2. Count the leaves.
3. Total: level by level
The master method:
The master method applies to recurrences of the form T(n) = aT(n/b) + f (n), where a ≥ 1, b > 1, and f is asymptotically positive.
Method:Compare f (n) with n^log(b)a:
case1: f(n) = O(n^[log(b)a – ε]) for some constant ε > 0.
Explain: f(n) grows polynomially slower than n^log(b)a (by an n^ε factor).
Solution: T(n) = Θ(n^log(b)a) .
Ex: T(n)=4T(n/2)+n ---------- a=4,b=2,f(n)=n.
n^log(b)a=n^2, f(n)=n=O(n^2), So the T(n)=Θ(n^2)
case2: f(n) = Θ(n^log(b)a*(lgn)^k) for some constant k ≥ 0.
Explain: f(n) and n^log(b)a grow at similar rates.
Solution: T(n) = Θ(n^log(b)a*(lgn)^(k+1)).
Ex: T(n)=4T(n/2)+n^2 ---------- a=4,b=2,f(n)=n^2.
n^log(b)a=n^2, f(n)=n^2=Θ(n^2*(lgn)^0), So the T(n)=Θ(n^2*lgn)
case3: f(n) = Ω(n^[log(b)a + ε]) for some constant ε > 0.
and f(n) satisfies the regularity condition that af(n/b) ≤ cf(n) for some constant c < 1.
(Under this condition, it can make sure that the consts decrease geometrically, Dominate: f(n))
Explain: f(n) grows polynomially faster than nlogba (by an n^ε factor),
Solution: T(n) = Θ(f (n)) .
Ex: T(n)=4T(n/2)+n^3 ---------- a=4,b=2,f(n)=n^3.
n^log(b)a=n^2, f(n)=n^3=Ω(n^2), So the T(n)=Θ(n^3)
- The notes of Algorithms ---- Solving Recurrences
- The notes of Algorithms ---- Asymptotic Notation
- The notes of Algorithms ---- Dynamic Programming
- The notes of Algorithms ---- Data Structures ---- Hash Table
- Time complexity analysis: solving recurrences
- The Importance of Algorithms
- The Importance of Algorithms
- Handbook of Applied Algorithms: Solving Scientific, Engineering, and Practical Problems
- Solving the absence of Android source...
- Paper Notes: Empirical Comparison of Algorithms for Network Community Detection
- greedy algorithms notes of Date Structure and Algorithms Analysis in C
- Solving the issue of installing mongodb on win8
- Machine Learning - Solving the Problem of Overfitting: Regularization
- the complexity of solving a l0-norm optimization problem
- the thinking and solving of local storage problem
- 读书笔记 day1:The design of approximation algorithms
- Algorithms--Heap Notes
- Algorithms--QuickSort Notes
- USACO Mixing Milk
- 从30岁到35岁:为你的生命多积累一些厚度
- USACO Calf Flac
- usaco 2.4 maze1
- USACO Prime Cryptarithm
- The notes of Algorithms ---- Solving Recurrences
- usaco 2.4 ttwo
- Linux下的多线程编程
- oracle获取系统毫秒数
- linux 安装PHP+MySql+Apache
- 学习OpenCV例2-6
- poj1088滑雪搜索dfs
- 数列求和
- 散列(开放定址法)