-2

I am solving a recurrence using repeated substitution method and I am almost done but it seems to me that I need some additional work to finish correctly. I am including an image of my work because typing would be very time-consuming. I will appreciate your feedback.

enter image description here

I can see that the problem says that $n = 2^k$ so $k = log_{2}n$ so I can replace every $k$ by $log_{2}n$

JORGE
  • 259
  • 3
  • 8

2 Answers2

2

Question:

$T(n) = 4T(\frac{n} {2})+n ,\hspace{0.5cm} if \hspace{0.5cm}n \geq 2 $

$\hspace{1.0cm} = 1 ,\hspace{2.2cm} if \hspace{0.5cm}n = 1 $

Solution by substitution method:

Generalized form:

$T(n) = 4^kT(\frac{n} {2^k})+n\sum_{n=1}^{k-1}2^i$

Until here you are good, but after this we can further simplify as below:

$\sum_{n=1}^{k-1}2^i$ is a finite geometric progression(GP), thus we use the formula:

$S_n=\frac{a_1(1-r^n)} {1-r} \hspace{0.5cm} when \hspace{0.5cm} r\neq1$

$S_n$ = sum of GP with n terms

$a_1$ = the first term

r = common ratio

n = number of terms

$T(n) = 4^kT(\frac{n} {2^k})+n(2^{k-1}-1)$

put $\frac{n} {2^k}= 1$ ie., $k=\log_2 n$

$T(n) = 1 ,\hspace{2.2cm} if \hspace{0.5cm}n = 1 $

$T(n) = 4^{\log_2 n}T(1)+n(\frac{n} {2}-1)$

$T(n) = n^{\log_2 4}+n(\frac{n} {2}-1)$

$T(n) = n^2+\frac{n^2} {2}-n$

Thus, $T(n)=O(n^2)$

Alwyn Mathew
  • 551
  • 2
  • 13
2

This is the guess & proof method as explained over at our reference question. You have a guess, now prove it correct! The canonical choice would be an inductive proof.

Raphael
  • 73,212
  • 30
  • 182
  • 400