1

How to solve the recurrence $T(n) = T(n/2) + T(n/4) + T(n/8)$?

We assume that $T(n)$ is constant for sufficiently small $n$.

hengxin
  • 9,541
  • 3
  • 36
  • 73

2 Answers2

2

We guess that $T(n) = \Theta(n^{\alpha})$, where $\alpha > 0$ is a constant.

To find $c$, we use the substitution method.

Assume that $T(n) \le cn^{\alpha}$. (The other direction $T(n) \ge cn^{\alpha}$ is similar.)

Then, we have $$T(n) \le c(n/2)^{\alpha} + c(n/4)^{\alpha} + c(n/8)^{\alpha}.$$

Letting $$c(n/2)^{\alpha} + c(n/4)^{\alpha} + c(n/8)^{\alpha} = cn^{\alpha},$$ we obtain that $$(1/2)^{\alpha} + (1/4)^{\alpha} + (1/8)^{\alpha} = 1.$$

Solving this equation (using Mathematica) yields $$\alpha = 0.879146.$$

hengxin
  • 9,541
  • 3
  • 36
  • 73
2

Use the Akra-Bazzi theorem, a generalization of the master theorem which captures recurrences such as yours. The method immediately gives $T(n) = \Theta(n^p)$, where $(1/2)^p + (1/4)^p + (1/8)^p = 1$.

In contrast to your method, the Akra-Bazzi theorem can also handle inhomogeneous recurrence relations (i.e., $T(n) = T(n/2) + T(n/4) + T(n/8) + g(n)$), and it can also handle floors and ceilings (i.e., $T(\lfloor n/2 \rfloor)$ instead of $T(n/2)$) and beyond.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503