[Math] unorthodox solution of a special case of the master theorem

recurrence-relationsrecursive algorithms

I am asking for references regarding a special case of the master theorem. This theorem seems to appear quite a lot on this site, prompting me to study it in more detail, e.g. see my posts here and here. It seems to me that it has some special cases which I will present to you that can be treated in a very simple way and without involving complicated machinery. This special case is the one where the cost at the recursion step is $n$ and the subproblems are obtained by dividing $n$ by powers of a single unique prime.

For example, take $T(0) = 0$ and consider the recurrence (the prime being two)
$$T(n) = T(n/2) + 3 T(n/4) +n.$$

Let $$n = \sum_{k=0}^{\lfloor \log_2 n \rfloor} d_k 2^k$$ be the binary representation of $n.$

It is not difficult to see that
$$ T(n) = \sum_{j=0}^{\lfloor \log_2 n \rfloor}
[z^j] \frac{1}{1-\frac{1}{2} z -\frac{3}{4} z^2}
\sum_{k=j}^{\lfloor \log_2 n \rfloor} d_k 2^k \tag{1}.$$
This formula is exact for all $n.$

Now we have $$[z^j] \frac{1}{1-\frac{1}{2} z -\frac{3}{4} z^2} =
\frac{2}{\sqrt 13}
\left( \left(\frac{1+\sqrt{13}}{4}\right)^{j+1} – \left(\frac{1-\sqrt {13}}{4}\right)^{j+1} \right) = \frac{2}{\sqrt{13}} \left(\rho_1^{j+1} – \rho_2^{j+1} \right), $$
where we have introduced $$\rho_{1,2} = \frac{1\pm\sqrt{13}}{4}.$$

To get a lower bound on $T(n)$, consider the case of a single one followed by zeros, giving
$$ T(n) \ge \frac{2}{\sqrt{13}} \sum_{j=0}^{\lfloor \log_2 n \rfloor}
\left(\rho_1^{j+1} – \rho_2^{j+1} \right) 2^{\lfloor \log_2 n \rfloor} =
\frac{2^{\lfloor \log_2 n \rfloor+1}}{\sqrt{13}}
\left( \frac{\rho_1^{\lfloor \log_2 n \rfloor+2}-1}{\rho_1-1}
– \frac{\rho_2^{\lfloor \log_2 n \rfloor+2}-1}{\rho_2-1} \right) .$$
This bound is actually attained.

For an upper bound, consider the case of a string of ones,
$$ T(n) \le \frac{2}{\sqrt{13}} \sum_{j=0}^{\lfloor \log_2 n \rfloor}
\left(\rho_1^{j+1} – \rho_2^{j+1} \right) \sum_{k=j}^{\lfloor \log_2 n \rfloor} 2^k =
\frac{2}{\sqrt{13}} \sum_{j=0}^{\lfloor \log_2 n \rfloor}
\left(\rho_1^{j+1} – \rho_2^{j+1} \right)
\left(2^{\lfloor \log_2 n \rfloor+1}-2^j\right) \\ =
\frac{2^{\lfloor \log_2 n \rfloor+2}}{\sqrt{13}}
\left( \frac{\rho_1^{\lfloor \log_2 n \rfloor+2}-1}{\rho_1-1}
– \frac{\rho_2^{\lfloor \log_2 n \rfloor+2}-1}{\rho_2-1} \right)
-\frac{1}{\sqrt{13}} \sum_{j=0}^{\lfloor \log_2 n \rfloor}
\left((2\rho_1)^{j+1} – (2\rho_2)^{j+1} \right).$$
The right term is $$-\frac{1}{\sqrt{13}}
\left( \frac{(2\rho_1)^{\lfloor \log_2 n \rfloor+2}-1}{2\rho_1-1}
– \frac{(2\rho_2)^{\lfloor \log_2 n \rfloor+2}-1}{2\rho_2-1} \right).$$
This bound too is attained. The spread between upper and lower is a factor of
$$ 2-2\frac{\rho_1-1}{2\rho_1-1}. $$

Taking these bounds together, we have shown that
$$ T(n) \in \Theta \left( (2\rho_1)^{\lfloor \log_2 n \rfloor} \right)
= \Theta \left( n 2^{\log_2 \rho_1 \log_2 n} \right) =
\Theta \left( n \times n^{\log_2 \rho_1} \right) =
\Theta \left(n^{1+\log_2 \rho_1} \right).$$
This trick generalizes to the case where the subproblem reductions are not powers of a unique prime which I leave to the reader. I would be happy to see references for the technique I have presented here. I am essentially asking whether it is new or not. From what I have seen the exact value of the exponent in the exponential is usually left untreated, whereas I have shown above that it can be made exact. Would you say that my use of a generating function to encapsulate the mechanics of the problem size reduction in the recurrence is new?

Here is another MSE computation that uses the same method.

Best Answer

A hands-on approach is to find some hereditary upper and lower bounds of $T(n)$ by multiples of powers of $n$.

If $T(n)=T(n/2)+3T(n/4)+n$, one first centers the recursion using $S(n)=T(n)+cn$, then $$ S(n)=S(n/2)-cn/2+3T(n/4)-3cn/4+n+cn=S(n/2)+3S(n/4), $$ if $c=4$. From now on, $S(n)=T(n)+4n$.

Thus, the centering step is based on the affine part of the recursion, here $+n$.

Second, assume that $S(k)\bowtie c k^a$ for $k=n/2$ and $k=3n/4$ with $a\gt1$, where $\bowtie$ is either $\leqslant$ or $\geqslant$. Then $S(n)\bowtie cn^a/2^a+c3n^a/4^a=(1/2^a+3/4^a)cn^a$. From now on, assume that $a$ solves $$ \frac1{2^a}+\frac3{4^a}=1. $$ Then the property $S(n)\bowtie cn^a$ is hereditary for every fixed $c$.

Thus, the power step is based on the linear part of the recursion, here $T(n/2)+3T(n/4)$.

In particular, for some small enough $c$ and some large enough $C$, it holds that $$ cn^a-4n\leqslant T(n)\leqslant Cn^a-4n, $$ for every $n$. Since $a\gt1$ in the present case, the contribution of the linear part of the recursion wins hence all this is more than enough to prove that $$ T(n)=\Theta(n^a). $$ One thing is clear though, which is that the fact that $1/2$ and $1/4$ are inverses of powers of a unique prime, invoked in the OP, does not enter the picture. Nevertheless, to relate $a$ to the exponent $\rho_1$ in the OP, assume that $a=1+\log_2\rho$, then $$ \frac1{2^a}+\frac3{4^a}=\frac1{2\rho}+\frac3{4\rho^2}, $$ hence $\rho$ solves $4\rho^2=2\rho+3$, that is, $\rho=\frac14(1\pm\sqrt{13})$, as claimed in the OP.

Edit: About the paragraph justifying the bounty, I would check the obvious references, namely generatingfunctionology and Flajolet's books.

Related Question