您的位置:首页 > 其它

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:





内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  算法导论