Quinn’s Mind Palace

Proof of the Master’s Theorem for Dividing Function

This is a simplified version of the proof of the Master’s Theorem for Dividing Functions. The gist of the proof lies in the rules of big-O notation—the bigger term “eats” the smaller term. Follow this proof and you’ll see how that applies.


Definition. Master Theorem for Dividing Function:

T(n)=aT(nb)+f(n), where f(n)nklogpn:

Case 1: If logba>k, then T(n)=O(nlogba).

Case 2: If logba=k, then:

Case 2-1: If p<1, then T(n)=O(nk).

Case 2-2: If p>1, then T(n)=O(nklogp+1n)=O(f(n)logn).

Case 2-3: If p=1, then T(n)=O(nklog(logn)).

Case 3: If logba<k, and f(n) satisfies the additional condition af(nb)cf(n) for some constant 0<c<1, then T(n)=O(f(n)).


Proof.

By the summation of the recursion tree with the height h=logbn:

T(n)=i=0haif(nbi)+O(ah).

The first term is all nodes except the leaves, the second term is the leaves.

Since ah=alogbn=nlogba, and substitute f(n) with nklogpn, we have

T(n)=i=0hai(nbi)klogp(nbi)+O(nlogba).

log(nbi)=log(blogbni)=log(bhi)logb(bhi)=hi.

Thus the first term i=0hai(nbi)klogp(nbi)nki=0haibik(hi)p.

Case 1

If logba>k, and because the first term would not exceed O(nklogbpn) which grows slower than the second term O(nlogba), thus

T(n)=O(nlogba).

Case 2

If logba=k, then aibik=aibilogba=aiai=1,

the first term becomes nki=0h(hi)p=nki=0hip.


A handy supporting lemma:

i=0ip converges if p<1 (harmonic series) and diverges otherwise;

i=0hip{lnh+γ,if p=1,hp+1p+1,if p>1.

(γ is the Euler–Mascheroni constant.)

Case 2-1

If p<1, then i=0hip<c for some constant c,

thus the first term reduces to cnk, and T(n)=O(nk).

Hence T(n)=O(nklog(logn)+nk)=O(nklog(logn)).

Case 2-2

If p>1, the first term nkhp+1=nklogbp+1nnklogp+1n.

Hence T(n)=O(nklogp+1n+nk)=O(nklogp+1n).

Case 2-3

If p=1, the first term nklnh=nkln(logbn)nklog(logn).

Case 3

If logba<k, then f(n)nklogpn>O(nlogba).

And with the additional condition af(nb)cf(n) for some constant 0<c<1, the first term i=0haif(nbi)i=0hcif(n)=f(n)i=0hci

f(n)i=0ci=f(n)11c=O(f(n)). (Geometric series)

Thus, T(n)=O(f(n))+O(nlogba)=O(f(n)).



Reference materials:

#Algorithms