0

$O(\sum_{l=0}^{log_2n} l*2^l)$. I took the integral of the term which I think is $O(n*log(n))$

Prikshet
  • 17
  • 1

1 Answers1

6

Let's give an upper and a lower bound:

  1. Lower bound: $$ \sum_{l=0}^{\log_2 n} l\cdot 2^l \ \geq \ \log_2n \, \cdot 2^{\log_2 n} \ = \ n \log_2 n \ , $$ so we can say that $\sum_{l=0}^{\log_2 n} l\cdot 2^l = \Omega(n\log n)$.

  2. Upper bound: \begin{align} \sum_{l=0}^{\log_2 n} l\cdot 2^l \ &\leq \ \sum_{l=0}^{\log_2 n} \log_2 n \cdot 2^l = \log_2 n \sum_{l=0}^{\log_2 n} 2^l \\ \\ &\leq \ \log_2n \cdot 2^{1+\log_2 n} \ = \ 2n\log_2 n \ , \end{align} where the second inequality derives from the fact that $\sum_{i=0}^n 2^i = 2^{n+1}-1$. Thus, we have $\sum_{l=0}^{\log_2 n} l\cdot 2^l = O(n\log n)$.

Summing up, we have that $\sum_{l=0}^{\log_2 n} l\cdot 2^l = \Theta(n\log n)$.

SilvioM
  • 1,339
  • 4
  • 13