2
$\begingroup$

How would you solve the recurrence $T(n) = n\cdot T(n/2)^2$? Could you use the master method? Or do you have to use iteration?

  • 0
    What are your own thoughts? And where did this problem come from? - Answering these two questions will greatly help you obtain the answer from the users of Math.SE2017-02-20
  • 0
    Take the logarithm of both sides and set $t(n):=\log T(n)$.2017-02-20
  • 0
    i will also try to find a formula for this problem2017-02-20

2 Answers 2

4

We have $$4nT(n) = \left(4\frac{n}{2}T(n/2)\right)^2$$ so that $$F(n) = F(n/2)^2 $$ where $F(n) = 4nT(n).$

Then take logs $$\ln(F(n)) = 2\ln(F(n/2)) $$

so that we have $$ G(n) = 2G(n/2)$$ where $G(n) = \ln(F(n)).$

The solution to this is obvious: when $n$ doubles, so does $G.$ Thus it is a linear function $$ G(n) = an.$$

Unwinding the transformations gives $F(n) = e^{an}$ and $T(n) = \frac{e^{an}}{4n}.$

As for your question about whether the master method works, I'm only familiar with that as a theorem about asymptotics, but when you take logs of the initial equation it immediately becomes a recurrence of that type and you can conclude that the log of the solution is $\Theta(n).$

0

This problem is also from exercise 53, of section 8.2, p.527, Kenneth Rosen - Discrete Mathematics and Its Applications 7th, where:

$$T\left(1\right)=6$$

The hint from the book is similar to @Yves Daoust suggestion. I solve this with 2 solutions. But firstly, I need to find the formula of this summation: $$\begin{align*} \left(\sum_{i=1}^{n}x^{i}\right)^{\prime}&=\sum_{i=1}^{n}ix^{i-1}\\\left(x\frac{x^{n}-1}{x-1}\right)^{\prime}&=\left(\frac{x^{n+1}-x}{x-1}\right)^{\prime}\\&=\frac{\left(x^{n+1}-x\right)^{\prime}\left(x-1\right)-\left(x^{n+1}-x\right)\left(x-1\right)^{\prime}}{\left(x-1\right)^{2}}\\&=\frac{\left[\left(n+1\right)x^{n}-1\right]\left(x-1\right)-\left(x^{n+1}-x\right)}{\left(x-1\right)^{2}}\\&=\frac{\left(n+1\right)x^{n+1}-\left(n+1\right)x^{n}-x+1-x^{n+1}+x}{\left(x-1\right)^{2}}\\&=\frac{nx^{n+1}-\left(n+1\right)x^{n}+1}{\left(x-1\right)^{2}}\\&\\\sum_{i=1}^{n}ix^{i-1}&=\frac{nx^{n+1}-\left(n+1\right)x^{n}+1}{\left(x-1\right)^{2}}\\\sum_{i=1}^{n}i2^{i}&=2\sum_{i=1}^{n}i2^{i-1}\\&=2\left[n2^{n+1}-\left(n+1\right)2^{n}+1\right]\\&=2\left[\left(n-1\right)2^{n}+1\right] \end{align*}$$


Solution 1:

$$\begin{align*} T\left(n\right)&=n\cdot T^{2}\left(\frac{n}{2}\right)\\\log_{2}T\left(n\right)&=\log_{2}n+2\log_{2}T\left(\frac{n}{2}\right)\\S\left(n\right)&=\log_{2}n+2S\left(\frac{n}{2}\right)\\S\left(2^{m}\right)&=m+2S\left(2^{m-1}\right)\\G\left(m\right)&=2G\left(m-1\right)+m\\&=2^{2}G\left(m-2\right)+2\left(m-1\right)+m\\&\cdots\\&=2^{m}G\left(0\right)+\sum_{i=0}^{m-1}2^{i}\left(m-i\right)\\&=2^{m}G\left(0\right)+m\sum_{i=0}^{m-1}2^{i}-\sum_{i=0}^{m-1}i2^{i}\\&=2^{m}G\left(0\right)+m\left(2^{m}-1\right)-2\left[\left(m-2\right)2^{m-1}+1\right]\\&=2^{m}G\left(0\right)+m2^{m}-m-2\left(m2^{m-1}-2^{m}+1\right)\\&=2^{m}G\left(0\right)+m2^{m}-m-m2^{m}+2^{m+1}-2\\&=2^{m}G\left(0\right)-m+2^{m+1}-2\\S\left(2^{m}\right)&=2^{m}S\left(2^{0}\right)-m+2^{m+1}-2\\&=nS\left(1\right)-m+2n-2\\T\left(n\right)&=\frac{T^{n}\left(1\right)\cdot4^{n}}{2^{m}\cdot4}\\&=\frac{T^{n}\left(1\right)\cdot4^{n-1}}{n} \end{align*}$$


Solution 2:

$$\begin{align*} T\left(n\right)&=nT^{2}\left(\frac{n}{2}\right)\\&=n\left[\frac{n}{2}T^{2}\left(\frac{n}{2^{2}}\right)\right]^{2}\\&=n\cdot\left(\frac{n}{2}\right)^{2}T^{2^{2}}\left(\frac{n}{2^{2}}\right)\\&=n\cdot\left(\frac{n}{2}\right)^{2}\left[\frac{n}{2^{2}}T^{2}\left(\frac{n}{2^{3}}\right)\right]^{2^{2}}\\&=n\cdot\left(\frac{n}{2}\right)^{2}\cdot\left(\frac{n}{2^{2}}\right)^{2^{2}}T^{2^{3}}\left(\frac{n}{2^{3}}\right)\\&=n\cdot\left(\frac{n}{2}\right)^{2}\cdot\left(\frac{n}{2^{2}}\right)^{2^{2}}\left[\frac{n}{2^{3}}T^{2}\left(\frac{n}{2^{4}}\right)\right]^{2^{3}}\\&=n\cdot\left(\frac{n}{2}\right)^{2}\cdot\left(\frac{n}{2^{2}}\right)^{2^{2}}\cdot\left(\frac{n}{2^{3}}\right)^{2^{3}}T^{2^{3}}\left(\frac{n}{2^{4}}\right)\\&\cdots\\&=\prod_{i=0}^{\log_{2}n-1}\left(\frac{n}{2^{i}}\right)^{2^{i}}T^{n}\left(1\right)\\&=\frac{n^{\sum_{i=0}^{\log_{2}n-1}2^{i}}}{2^{\sum_{i=0}^{\log_{2}n-1}i2^{i}}}6^{n}\\&=\frac{n^{\sum_{i=0}^{\left\lfloor \log_{2}n-1\right\rfloor }2^{i}+2^{\log_{2}n-1-\left\lfloor \log_{2}n-1\right\rfloor }}}{2^{\sum_{i=0}^{\left\lfloor \log_{2}n-1\right\rfloor }i2^{i}+\left(\log_{2}n-1-\left\lfloor \log_{2}n-1\right\rfloor \right)2^{\log_{2}n-1-\left\lfloor \log_{2}n-1\right\rfloor }}}6^{n}\\&=\frac{n^{2^{\left\lfloor \log_{2}n-1\right\rfloor +1}-1}\cdot n^{2^{\log_{2}n-1-\left\lfloor \log_{2}n-1\right\rfloor }}}{2^{2\left[\left(\left\lfloor \log_{2}n-1\right\rfloor -1\right)2^{\left\lfloor \log_{2}n-1\right\rfloor +1}+1\right]}\cdot2^{\left(\log_{2}n-1-\left\lfloor \log_{2}n-1\right\rfloor \right)2^{\log_{2}n-1-\left\lfloor \log_{2}n-1\right\rfloor }}}6^{n}\\&=\frac{n^{2^{\left\lfloor \log_{2}n\right\rfloor }-1}\cdot n^{2^{\log_{2}n-\left\lfloor \log_{2}n\right\rfloor }}}{2^{2\left[\left\lfloor \log_{2}n-2\right\rfloor 2^{\left\lfloor \log_{2}n-1\right\rfloor }+1\right]}\cdot2^{\left(\log_{2}n-\left\lfloor \log_{2}n\right\rfloor \right)2^{\log_{2}n-\left\lfloor \log_{2}n\right\rfloor }}}6^{n}\\&=\frac{n^{2^{\left\lfloor \log_{2}n\right\rfloor }-1}\cdot n^{2^{\log_{2}n-\left\lfloor \log_{2}n\right\rfloor }}}{2^{\left\lfloor \log_{2}n-2\right\rfloor 2^{\left\lfloor \log_{2}n\right\rfloor }+2}\cdot2^{\left(\log_{2}n-\left\lfloor \log_{2}n\right\rfloor \right)2^{\log_{2}n-\left\lfloor \log_{2}n\right\rfloor }}}6^{n}\\&\\n&=2^{m}\\T\left(n\right)&=\frac{n^{2^{m}-1}}{2^{\left(m-2\right)2^{m}+2}}6^{n}\\&=\frac{n^{n-1}}{2^{n\left(m-2\right)+2}}6^{n}\\&=\frac{n^{n-1}}{4\left(2^{m-2}\right)^{n}}6^{n}\\&=\frac{6^{n}n^{n-1}4^{n}}{4\cdot n^{n}}\\&=\frac{6^{n}\cdot4^{n-1}}{n} \end{align*}$$