2

This question has already been asked before in this site, but the details of none of them is my question and none of them answer my question. The following is an example recurrence given in introduction to algorithms book by CLRS .

$$T(n) = 2T(\sqrt n) + \log n$$

It is solved by changing the variables. It renames the $m = \log n$ and it yields

$$T(2^m) = 2T(2^{m/2}) + m$$

and it renames $S(m) = T(2^m)$, so it produces new recurrence

$$ S(m) = 2S(m/2) + m $$

which is easy to solve.

I have two problems with this solution:

1- renaming $S(m) = T(2^m)$ must yield $S(m) = S(m/2) + \log m$, since we can't change the argument of the $T$ and leave the $m$ as it was. We can use $S(m) = S(m/2) + m$ only if the original recurrence was $T(2^m) = 2T(2^{m/2}) + 2^m$

2- The second problem is, even if the above renaming is true, $2T(\dfrac{2^m}{2})$ would be $S(m/2)$ not the $2T(2^{m/2})$

thanks in advance.

Raphael
  • 72,336
  • 29
  • 179
  • 389
M a m a D
  • 1,529
  • 2
  • 18
  • 30

1 Answers1

1

Regarding your 1st problem: You don't need to change $m$ to $\log m$. Let's suppose $f(x)=g(y)$.Then you do not need substitute $y$ anywhere. Because $y$ if substituted would again produce $y$. If you substitute $y$, you must substitute it by $g^{-1}f(x)$=$g^{-1}g(y)=y$. You can see you are again getting $y$.

Regarding your second problem: $S(m)=T(2^m)$

Let $y=m/2$

$$S(y)=T(2^y)$$

$$S(m/2)=T(2^{m/2})$$

You must substitute $m$ by $m/2$. What you are doing is dividing $2^m$ by $2$ which is completely wrong.

M a m a D
  • 1,529
  • 2
  • 18
  • 30
Kishan Kumar
  • 705
  • 1
  • 8
  • 23
  • To avoid confusion, let's rename $T(2^m)$ to $S(t)$. Clearly $T(2^m) = 2T(2^{m/2}) + m$ should be $S(t) = S(t/2) + m$. But what the book says, it writes $S(t) = S(t/2) + t$ which confuses me. – M a m a D Oct 21 '17 at 14:26
  • If you replace $T(2^m)$ by S(t) then T($2^{m/2}$) would become S($t^{1/2}$). Hence you would get back your original equation S(t)=S($t^{1/2})$+m. – Kishan Kumar Oct 21 '17 at 17:04
  • You are taking different variables in T and S. That's what causing the problem. – Kishan Kumar Oct 21 '17 at 17:10