Asymptotic Notation and Recurrences
2013-12-16 17:06
471 查看
Asymptotic notation
Θ-notationΘ(g(n))
= {f(n) : there exist positive constants c1, c2,
and n0 such that 0 ≤ c1g(n) ≤ f(n) ≤ c2g(n)
for all n ≥ n0}
O-notation
O(g(n))
= {f(n): there exist positive constants c and n0 such
that 0 ≤ f(n) ≤ cg(n)
for all n ≥ n0}.
Ω-notation
Ω(g(n))
= {f(n): there exist positive constants c and n0 such
that 0 ≤ cg(n) ≤ f(n)
for all n ≥ n0}.
Theorem 3.1
For any two functions f(n) and g(n),
we have f(n) = Θ(g(n))
if and only if f(n) = O(g(n))
and f(n) = Ω(g(n)).
T (n) = 4T (n / 2) + n
How to know the T(n) = O(f(n)), what is f(n)?
We can guess it for experience.
set f(n) = c.n^3; (n^3 means power(n,3));
prove this:
T (n) = 4T (n / 2) + n
≤ 4c ( n / 2 ) 3 + n
= ( c / 2) n 3 + n
desired – residual
= cn3 − ((c / 2)n3 − n)
≤ cn3 desired
OK , T(n) = O(n^3);
But we can't guess for any one, we can use recurrences.
T(n) = T(n/4) + T(n/2) + n^2
think this case:
相关文章推荐
- The notes of Algorithms ---- Asymptotic Notation
- asymptotic notation and recursion
- 【译】 Using JSON (JavaScript Object Notation) with Yahoo! Web Services(z)
- Abstract Syntax Notation One
- JSON (JavaScript Object Notation)
- Ajax中数据传递的另一种模式 javascript Object Notation思想(JSON)
- Ajax/JavaScript学习随笔:java script Object Notation(JSON)
- DotNotation
- CIDR Notation
- Leetcode: Evaluate Reverse Polish Notation
- FWNX-Evaluate Reverse Polish Notation -c++ VERSION-solution accepted
- DMN 决策模型和标记 Decision Model And Notation
- LeetCode - Evaluate Reverse Polish Notation
- [Leetcode Soution]Evaluate Reverse Polish Notation
- Evaluate Reverse Polish Notation
- [leetCode]:Evaluate Reverse Polish Notation
- LeetCode | Evaluate Reverse Polish Notation
- LeetCode Evaluate Reverse Polish Notation
- JSON(JavaScript Object Notation)内容详解(Android操作JSON)
- LeetCode: Evaluate Reverse Polish Notation [150]