2

Show by induction that any solution to a recurrence of the form $ T(n) \le 2T(n/3) + c\log_3 n $ is $O(n\log_3 n)$.

Hoping someone can help me with the correct solution. I attempted two ways to get the solution (but I think that they're both incorrect):

SOLUTION A

\begin{align} T(n) &\le 2T(n/3) + c \log_3 n \\ &\leq 2[k(n/3)\log_3(n/3)] + c\log_3 n \\ &= (2/3)kn(\log_3 n-1) + c\log_3 n \\ &= (2/3)(kn)\log_3 n \\ &= (2/3)kn + c\log_3n \\ &= [(2/3)kn + c]\log_3n - (2/3)kn \end{align}

SOLUTION B

\begin{align} T(n) &\le 2T(n/3) + c \log_3n \\ &\le 2 [ k(n/3)\log_3(n/3) ] + c \log_3n \\ &= (kn - kn/3)(\log_3n - 1) + c \log_3n \\ &= (kn)\log_3n - (kn/3)\log_3n - kn + c\log_3n \\ &= (kn)\log_3n - (2/3)kn + (c - kn/3)\log_3n \end{align}

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503
swabygw
  • 121
  • 2

1 Answers1

1

Here is what happens when you use the substitution method, assuming a base case of $T(1) = 0$ and $c=1$: \begin{align} T(3^m) &\leq m + 2T(3^{m-1}) \\ &\leq m + 2(m-1) + 2^2T(3^{m-2}) \\ &\leq m + 2(m-1) + 2^2(m-2) + 2^3T(3^{m-3}) \\ &\leq \ldots \\ &\leq m + 2(m-1) + 2^2(m-2) + \cdots + 2^{m-1}(1) + 2^m T(1) \\ &= m + 2(m-1) + 2^2(m-2) + \cdots + 2^{m-1}(1) \\ &= m(1 + 2 + \cdots + 2^{m-1}) - (2 + 2^2 + \cdots + 2^{m-1}) - (2^2 + \cdots + 2^{m-1}) - \cdots - (2^{m-1}) \\ &= m(2^m-1) - (2^m-2) - (2^m-2^2) - \cdots - (2^m-2^{m-1}) \\ &= m(2^m-1) - (m-1)2^m + (2 + 2^2 + \cdots + 2^{m-1}) \\ &= m(2^m-1) - (m-1)2^m + (2^m-2) \\ &= 2^{m+1}-m-2. \end{align} This shows that $T(n) = O(n^{\log_32})$.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503
  • Interesting substitution. Can you explain, though, how O[n^(log(3)2)] matches O[n*log(3)n], please? – swabygw Jun 03 '20 at 03:30
  • I should've added: note that your log in big O is an exponent and the log in my big O is not an exponent, it's part of a product. – swabygw Jun 03 '20 at 03:49
  • The bound I get is better than what you aim for. – Yuval Filmus Jun 03 '20 at 06:05
  • My substitution is actually not so interesting. Rather, it is standard and routine. – Yuval Filmus Jun 03 '20 at 06:06
  • Agreed - your bound is better. But I'm stuck with doing what my textbook assignment asked for, so is it possible to get to O[n*log(3)n] ? – swabygw Jun 03 '20 at 23:10
  • This follows immediately from my bound. – Yuval Filmus Jun 04 '20 at 05:31
  • I don't see how it follows - can you show/explain that? – swabygw Jun 05 '20 at 01:51
  • Here’s a simpler example. If $c \leq 10$ then $c \leq 20$. – Yuval Filmus Jun 05 '20 at 06:01
  • I understand the concept that a stronger than required bound is better than a weaker bound. But, again, I have to reach, and prove, the conclusion posed by the published assignment and the published answer. Thanks anyway. – swabygw Jun 05 '20 at 16:55
  • If you know that $T(n) = O(n^{\log_3 2})$, then it immediately follows that $T(n) = O(n \log n)$. There is nothing more to prove. – Yuval Filmus Jun 05 '20 at 17:28
  • Big O is an upper bound. If n=3, then "n log n" equals 3, and "n^log(3)2" equals 2, and thus "n log n" is the bigger bound, which doesn't follow "n^log(3)2". – swabygw Jun 05 '20 at 22:04
  • Big O is an asymptotic upper bound. It is definitely the case that $n^{\log_32} = O(n\log n)$. – Yuval Filmus Jun 05 '20 at 22:32
  • Nope, sorry, that's not the case, but I won't take up any more space debating it. But, thanks, again, for the discussion. – swabygw Jun 05 '20 at 22:41
  • In fact, it is the case. I agree that there’s no point debating it. I just suggest to compare our credentials and experience. – Yuval Filmus Jun 05 '20 at 22:59
  • Please...I went to one of those schools (I'm quite older than you) and, given that the answer is wrong, the arrogance is embarrassing. – swabygw Jun 06 '20 at 00:19
  • By the way, if you replace $2T(n/3)$ by $3T(n/3)$ in the original recurrence then the solution does become $\Theta(n\log n)$. In your case the solution is $\Theta(n^{\log_32})$, which is asymptotically smaller. You can get the same results from the master theorem. – Yuval Filmus Jun 06 '20 at 05:02