Chapter.2 Asymptotic notation&Recurrence's Asymptotic time

Asymptotic notation

big-O notation(O means upper bound in soome way)

f(n) = O(g(n)) means there are consts c>0,n0>0 such that 0<=f(n)<c*g(n) for all
n>=n0.Notation "=" means "belong to" rather than "equal",thus Equal sign is irreversible.
Here, O(g(n)) presents a function set that satisfy the rules above.

Ex.

  • f(n) = n^ 3+O(n ^2)
    • means there is a function h(n)∈O(n ^2) such that f(n) = n ^3+h(n)
  • n ^2+O(n) = O(n ^2)
    • means for any f(n)∈O(n), there is a h(n)∈O(n ^2) such that n ^2+f(n) = h(n).

Reminder->Macro convention is also introduced in this chapter,but I don’t remember what it’s meaning.

big-omega notation(Ω means lower bound in some way)

f(n)= Ω(g(n)) means there are consts c>0,n0>0 such that 0<=cg(n)<f(n) for all n>=n0.

Ex.

  • sqrt(n) = Ω(lgn)
    • means there are function h(n)∈Ω(lgn) such that sqrt(n) = h(n).

Other notations

Notation Meaning Ex
ω > n^3= w(n ^2)
Ω >= sqrt(n) = Ω(lgn)
o < n ^2+O(n) = o(n ^3)
O >= n ^2+O(n) = O(n ^2)
Θ == n ^2 = Θ(n ^2)

Methods for solving recurrences

substitution method

  1. Guess the form of the solution(such as n ^2,n ^4-n…)
  2. Verify by induction.
  3. solve for consts.

Ex.
T(n)=4T(n/2)+n

  • Idea 1 //
    To assume T(n) = O(n ^3), then T(k) <=c*k ^3,
    T(n) = 4T(n/2)+n <=4c(n/2)^ 3+n=(cn^ 3)/2+n=cn^ 3-((cn^ 3)/2-n).
    To satisfy this, we need (cn^ 3)/2-n <=0 &&( T(1) = O(1) <= c ^3), thus we have T(n)=4T(n/2)+n when c is a suffiently large and n>=2.

  • Idea 2 //
    To assume T(n) = O(n ^2), then T(k) <= c*k ^2,
    T(n)=4T(n/2)+n<=4c(n/2)^ 2+n=cn^ 2+n=cn^2-(-n).The same is true,to satisfy this, we need (-n) nonnegative.However,it is no way.

  • Idea 3//
    To assume T(n) = O(n ^2), then T(k) <= c1k ^2 - c2k.
    T(n)=4T(n/2)+n<=4(c1·(n/2)^ 2-c2·(n/2))+n=c1·n^2-c2·n-(-1+c2)·n。The same is true with Idea1.

Recursion-Tree Method

The method is not rigorous bur easier,we can apply it firstly and then verify solution by substitution method.
Ex.

  • T(n) = T(n/4) + T(n/2) + n ^2
    在这里插入图片描述

Master Method

Attention: This method is solely applied to recurrences of the form like follows

T(n)=aT(n/b)+f(n)(a>=1 b>1 f(n) asymptotic positive)
  • Case1:
    f(n)=O(n^(log(b)a-ε)) (ε>0)
    =>T(n)=Θ(n^log(b)a)

  • Casse2:
    f(n)=Θ (nlog(b)a·(lgn)k)(k>=0)
    =>T(n)=Θ(nlog(b)a·(lgn)(k+1))

  • Case3
    f(n)=Ω(n^(log(b)a+ε))(ε>0)&& exist 0<ε‘<1,such that af(n/b)<=(1-ε’)·f(n)
    =>T(n)=Θ(f(n))

Ex

  • T(n)=4T(n/2)+n
  1. n^ log(b)a=n^2
  2. We konw that f(n)= n <n ^2,thus this is case 1.T(n) = Θ(n ^2).
  • T(n)=4T(n/2)+n^2
  1. n^ log(b)a=n^2
  2. We konw that f(n)= n ^2 = n ^2,thus this is case 2.T(n) = Θ(n ^2lgn).
  • T(n)=4T(n/2)+n^3
    1) n^ log(b)a=n^2
    2) We konw that f(n)= n ^3 > n ^2,thus this is case 3.T(n) = Θ(n ^3).

  • T(n)=4T(n/2)+n^2/lgn
    Master method is not applied, use recursion-tree maybe.

What’s more, the proof sketch of master method is introduced in this chapter. We ignore it here.

发布了80 篇原创文章 · 获赞 332 · 访问量 70万+

猜你喜欢

转载自blog.csdn.net/qq_40527086/article/details/103148775