Let's think about the recursion tree corresponding to a divide-and-conquer algorithm that at each stage makes
a recursive calls on inputs of size
n/b, and does
\Theta (n^d) extra work besides the recursive calls.
- The tree has height \log _b n.
- A node at level k has size n/b^k and does (n/b^k)^d work.
- There are a^k nodes at level k, so the total work at level k is a^k \cdot \left (\frac {n}{b^k}\right )^d = n^d \left (\frac {a}{b^d}\right )^k.
Hence the overall total work is \sum _{k=0}^{\log _b n}
n^d \left (\frac {a}{b^d}\right )^k = n^d \sum _{k=0}^{\log _b n}
\left (\frac {a}{b^d}\right )^k. This is n^d times a geometric series with ratio a/b^d.
- If a < b^d then the ratio is < 1 and the sum is a constant; hence the total work is \Theta (n^d).
- If a = b^d then the ratio is 1 and the sum is \Theta (\log _b n); hence the total work is \Theta (n^d \log n).
- If a > b^d then the ratio is > 1 and the sum is proportional to its final term, (a/b^d)^{\log _b n}. In that case the total work is \Theta \left ( n^d \cdot \left (\frac {a}{b^d}\right )^{\log _b n} \right ) =
\Theta \left ( n^d \cdot \frac {a^{\log _b n}}{(b^{\log _b n})^d}\right ) = \Theta (a^{\log _b
n}) = \Theta (n^{\log _b a}).