Recurrence Relations · Application: Divide and Conquer
Lesson 6
Now we are ready to prove the theorem about recurrence relations.
Proof. Expand the recurrence relation \(T(n)=cn^{d}+aT(n/b)\): \[\begin{align*}T(n)&=cn^{d}+aT(n/b)\\&=cn^{d}+a(c(n/b)^{d}+aT(n/b^{2}))=cn^{d}+ca(n/b)^{d}+a^{2}T(n/b^{2})=\\&\vdots\\&=cn^{d}+ca(n/b)^{d}+ca^{2}(n/b^{2})^{d}+\dotsb=\\&=\sum_{l=0}^{\log_bn}ca^{l}\left(\frac{n}{b^l}\right)^{d}=\\&=\sum_{l=0}^{\log_bn}a^{l} \cdot c \cdot \frac{n^d}{b^{ld}}=\\&=cn^{d}\sum_{l=0}^{\log_bn}\frac{a^l}{b^{ld}}=\\&=cn^{d}\sum_{l=0}^{\log_bn}\left(\frac{a}{b^{d}}\right)^{l}=\\&=cn^{d}\sum_{l=0}^{\log_bn}\alpha^{l},\end{align*}\] where \(\alpha=\frac{a}{b^d}\). Below, we show a slightly more visual method of deriving this formula. We will then estimate the resulting expression.
The recursion tree of the algorithm is shown below. For each level, the number of problems, their sizes, and the total work performed by the algorithm at that level are displayed.

Consider three cases.
- \(a>b^{d}\). Then \[cn^{d}\cdot \left(\frac{a}{b^{d}}\right)^{\log_{b}n}=cn^{d} \cdot \frac{a^{\log_{b}n}}{b^{d\log_{b}n}}= cn^{d}\cdot \frac{n^{\log_{b}a}}{n^d}=c\cdot n^{\log_{b}a}=O(n^{\log_{b}a}) \ .\] (We used the equalities \(a^{\log_{b}n}=n^{\log_{b}a}\) and \(b^{\log_{b}n}=n\).)
- \(a=b^{d}\). Then \[cn^{d} \cdot O(\log_{b}n)=O(n^{d}\log n) \ .\] (The logarithm base inside \(O(\cdot)\) can be omitted if it is constant.)
- \(a<b^{d}\). Then \[cn^{d}\cdot O(1)=O(n^{d}) \ .\]