Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

While evaluating the complexity of an algorithm, I got an inequality that I am unable to understand.

Let us consider this series:

$$x= n + (2^0 + 2^1 + 2^2 + ....... + 2^{\lfloor\log(n-1)\rfloor})$$

How do I prove that $x\leq 3n$ ?

Please help me understand this intuitively or otherwise.

share|improve this question

1 Answer 1

The key is the identity $$ \sum_{i=0}^{m}2^{i} = 2^{m+1}-1 $$

Then just plugging in $m=\lfloor\log(n-1)\rfloor$ we get $$ x = n + (2^{\lfloor\log(n-1)\rfloor+1}-1) $$ It should be obvious from there.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.