3
$\begingroup$

$(1)$ The first relation. $$ \left\lfloor \log_2\frac{n}{i} \right\rfloor=j \Longleftrightarrow 2^j \leq \frac{n}{i} < 2^{j+1} \Longleftrightarrow \frac{n}{2^{j+1}} < i \leq \frac{n}{2^j} \space\space $$

Therefore, $(2)$ The second relation as follows $$ \sum_{i=1}^n\left\lfloor \log_2\frac{n}{i} \right\rfloor\leq \sum_{j=1}^{\lfloor \log_2n \rfloor}j\cdot\left(\frac{n}{2^{j+1}}+1\right)=O(\log^2n)+n \cdot \sum_{j=1}^{\infty}{\frac{j}{2^{j+1}}}=O(\log^2n)+n $$

I don't know how can we get $(2)$ from $(1)$; Moreover, why and how can we simplify $(2)$ like that.

$\endgroup$
1
  • 1
    $\begingroup$ @Arthur sorry for my typo. I will add it now. $\endgroup$
    – ident
    Commented Sep 27, 2023 at 8:48

1 Answer 1

4
$\begingroup$

By $(1)$, the number of integers $i$ such that $\left\lfloor \log_2\frac{n}{i} \right\rfloor=j$ is $$\left\lfloor \frac n{2^j}\right\rfloor-\left\lceil\frac n{2^{j+1}}\right\rceil+1\le\frac n{2^j}-\frac n{2^{j+1}}+1=\frac n{2^{j+1}}+1,$$ whence the $\le$ in $(2).$

For the next $=,$ use that $$\sum_{j=1}^{\lfloor \log_2n \rfloor}j=\frac{\lfloor \log_2n \rfloor(\lfloor \log_2n \rfloor+1)}2\le \frac{(\log_2n)(\log_2n+1)}2=O(\log_2^2n).$$

Finally, $$\sum_{j=1}^{\infty}{\frac{j}{2^{j+1}}}=1.$$

$\endgroup$
1
  • 1
    $\begingroup$ Thank you. I wish you all the best. $\endgroup$
    – ident
    Commented Sep 27, 2023 at 9:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .