Proof of Master Theorem

Master Theorem
T ( n ) = a T ( n b ) + f ( n ) T(n)=aT\left(\dfrac{n}{b}\right)+f(n) T(n)=aT(bn)+f(n)
where a ≥ 1 , b > 1 a\geq 1, b>1 a1,b>1, a , b a,b a,b is constant, n b \dfrac{n}{b} bn can be either ⌊ n b ⌋ \lfloor \dfrac{n}{b} \rfloor bn or ⌈ n b ⌉ \lceil \dfrac{n}{b} \rceil bn

  1. ∃ ϵ > 0   s . t .   f ( n ) = O ( n log ⁡ b a − ϵ ) \exist \epsilon>0 \ s.t. \ f(n)=O(n^{\log_b a-\epsilon}) ϵ>0 s.t. f(n)=O(nlogbaϵ), then T ( n ) = Θ ( n log ⁡ b a − ϵ ) T(n)=\Theta(n^{\log_b a-\epsilon}) T(n)=Θ(nlogbaϵ)
  2. f ( n ) = Θ ( n log ⁡ b a log ⁡ k n ) f(n)=\Theta(n^{\log_b a}\log^k n) f(n)=Θ(nlogbalogkn), then T ( n ) = Θ ( n log ⁡ b a log ⁡ k + 1 n ) T(n)=\Theta(n^{\log_b a}\log^{k+1}n) T(n)=Θ(nlogbalogk+1n)
  3. ∃ ϵ > 0   s . t .   f ( n ) = Ω ( n log ⁡ b a + ϵ ) \exist \epsilon>0\ s.t.\ f(n)=\Omega(n^{\log_b a+\epsilon}) ϵ>0 s.t. f(n)=Ω(nlogba+ϵ), and a f ( n b ) ≤ c f ( n ) af\left(\dfrac{n}{b}\right)\leq cf(n) af(bn)cf(n) holds for some constant c < 1 c<1 c<1 and all sufficiently large n n n (usually called the regularity condition), then T ( n ) = Θ ( f ( n ) ) T(n)=\Theta(f(n)) T(n)=Θ(f(n))

Proof:

T ( n ) = a T ( n b ) + f ( n ) ⇔ T ( n ) = Θ ( n log ⁡ b a ) + ∑ i = 0 log ⁡ b n − 1 a i f ( n b i ) T(n)=aT\left(\dfrac{n}{b}\right)+f(n) \Leftrightarrow T(n) = \Theta(n^{\log_b a})+\sum_{i=0}^{\log_b n - 1} a^i f\left(\dfrac{n}{b^i}\right) T(n)=aT(bn)+f(n)T(n)=Θ(nlogba)+i=0logbn1aif(bin)

Obviously T ( n ) T(n) T(n) depends on case of f ( n ) f(n) f(n), now let
g ( n ) = ∑ i = 0 log ⁡ b n − 1 a i f ( n b i ) g(n)=\sum_{i=0}^{\log_b n - 1}a^i f\left(\dfrac{n}{b^i}\right) g(n)=i=0logbn1aif(bin)

Case 1 : ∃ ϵ > 0   s . t .   f ( n ) = O ( n log ⁡ b a − ϵ ) \exist \epsilon>0 \ s.t. \ f(n)=O(n^{\log_b a-\epsilon}) ϵ>0 s.t. f(n)=O(nlogbaϵ)
g ( n ) = ∑ i = 0 log ⁡ b n − 1 a i f ( n b i ) = O ( ∑ i = 0 log ⁡ b n − 1 a i ( n b i ) log ⁡ b a − ϵ ) g(n)=\sum_{i=0}^{\log_b n - 1}a^i f\left(\dfrac{n}{b^i}\right)=O(\sum_{i=0}^{\log_b n - 1} a^i\left(\dfrac{n}{b^i} \right)^{\log_b a - \epsilon}) g(n)=i=0logbn1aif(bin)=O(i=0logbn1ai(bin)logbaϵ)
Simplification
∑ i = 0 log ⁡ b n − 1 a i ( n b i ) log ⁡ b a − ϵ \sum_{i=0}^{\log_b n - 1} a^i\left(\dfrac{n}{b^i} \right)^{\log_b a - \epsilon} i=0logbn1ai(bin)logbaϵ
= n log ⁡ b a − ϵ ∑ i = 0 log ⁡ b n − 1 b ϵ i =n^{\log_b a-\epsilon}\sum_{i=0}^{\log_b n - 1}b^{\epsilon i} =nlogbaϵi=0logbn1bϵi
= n log ⁡ b a − ϵ n ϵ − 1 b ϵ − 1 =n^{\log_b a-\epsilon}\dfrac{n^{\epsilon} - 1}{b^{\epsilon} - 1} =nlogbaϵbϵ1nϵ1
⇒ g ( n ) = O ( n log ⁡ b a ) \Rightarrow g(n)=O(n^{\log_ba}) g(n)=O(nlogba)
T ( n ) = Θ ( n log ⁡ b a ) + g ( n ) = Θ ( n log ⁡ b a ) T(n)=\Theta(n^{\log_b a})+g(n)=\Theta(n^{\log_b a }) T(n)=Θ(nlogba)+g(n)=Θ(nlogba)
Case 2 : f ( n ) = Θ ( n log ⁡ b a log ⁡ k n ) f(n)=\Theta(n^{\log_b a}\log^k n) f(n)=Θ(nlogbalogkn)
g ( n ) = ∑ i = 0 log ⁡ b n − 1 a i f ( n b i ) = Θ ( ∑ i = 0 log ⁡ b n − 1 a i ( n b i ) log ⁡ b a log ⁡ k n ) g(n)=\sum_{i=0}^{\log_b n - 1}a^i f\left(\dfrac{n}{b^i}\right)=\Theta(\sum_{i=0}^{\log_b n - 1} a^i \left(\dfrac{n}{b^i}\right)^{\log_b a}\log^k n) g(n)=i=0logbn1aif(bin)=Θ(i=0logbn1ai(bin)logbalogkn)
= Θ ( n log ⁡ b a log ⁡ k n ∑ i = 0 log ⁡ b n − 1 1 ) =\Theta(n^{\log_b a} \log^k n \sum_{i=0}^{\log_b n - 1}1) =Θ(nlogbalogkni=0logbn11)
= Θ ( n log ⁡ b a log ⁡ k n log ⁡ b n ) =\Theta(n^{\log_b a} \log^k n \log_b n) =Θ(nlogbalogknlogbn)
= Θ ( n log ⁡ b a log ⁡ k + 1 n ) =\Theta(n^{\log_b a} \log^{k+1} n) =Θ(nlogbalogk+1n)

Case 3 : ∃ ϵ > 0   s . t .   f ( n ) = Ω ( n log ⁡ b a + ϵ ) \exist \epsilon>0\ s.t.\ f(n)=\Omega(n^{\log_b a+\epsilon}) ϵ>0 s.t. f(n)=Ω(nlogba+ϵ), and a f ( n b ) ≤ c f ( n ) af\left(\dfrac{n}{b}\right)\leq cf(n) af(bn)cf(n) holds for some constant c < 1 c<1 c<1 and all sufficiently large n n n (usually called the regularity condition)
a f ( n b ) ≤ c f ( n ) ⇔ f ( n b ) ≤ c a f ( n ) ⇔ f ( n b i ) ≤ ( c a ) i f ( n ) ⇔ a i f ( n b i ) ≤ c i f ( n ) af\left(\dfrac{n}{b}\right)\leq cf(n) \Leftrightarrow f\left(\dfrac{n}{b}\right) \leq \dfrac{c}{a} f(n) \Leftrightarrow f\left(\dfrac{n}{b^i}\right) \leq \left(\dfrac{c}{a}\right)^i f(n) \Leftrightarrow a^i f\left(\dfrac{n}{b^i}\right) \leq c^i f(n) af(bn)cf(n)f(bn)acf(n)f(bin)(ac)if(n)aif(bin)cif(n)

g ( n ) = ∑ i = 0 log ⁡ b n − 1 a i f ( n b i ) ≤ ∑ i = 0 log ⁡ b n − 1 c i f ( n ) ≤ ∑ i ≥ 0 c i f ( n ) = 1 1 − c f ( n ) g(n) = \sum_{i=0}^{\log_b n - 1} a^i f\left(\dfrac{n}{b^i}\right) \leq \sum_{i=0}^{\log_b n - 1}c^if(n) \leq \sum_{i \geq 0}c^if(n)=\dfrac{1}{1-c}f(n) g(n)=i=0logbn1aif(bin)i=0logbn1cif(n)i0cif(n)=1c1f(n)
⇒ g ( n ) = O ( f ( n ) ) \Rightarrow g(n)=O(f(n)) g(n)=O(f(n))
On the other hand
g ( n ) = ∑ i = 0 log ⁡ b n − 1 a i f ( n b i ) ≥ f ( n ) g(n)=\sum_{i=0}^{\log_b n - 1} a^i f\left(\dfrac{n}{b^i}\right) \geq f(n) g(n)=i=0logbn1aif(bin)f(n)
⇒ g ( n ) = Ω ( f ( n ) ) \Rightarrow g(n)=\Omega(f(n)) g(n)=Ω(f(n))
Thus
g ( n ) = Θ ( f ( n ) ) g(n)=\Theta(f(n)) g(n)=Θ(f(n))
T ( n ) = Θ ( n log ⁡ b n ) + Θ ( f ( n ) ) = Θ ( f ( n ) ) T(n)=\Theta(n^{\log_b n })+\Theta(f(n))=\Theta(f(n)) T(n)=Θ(nlogbn)+Θ(f(n))=Θ(f(n))

你可能感兴趣的:(算法,Master,Theorem)