if n == 4 -> log2(4) = 2 , but 4 has only one set bit : 100 ?
if n == 7 -> log2(7) = 2 , but 7 has three set bits : 111?
if n == 15 -> log2(15) = 3 , but 15 has 4 set bits : 1111?
if n == 9 -> log2(9) = 3 , but 9 has only 2 set bits : 1001?
How is the maximum number of set bits in a number equal to log2(n)?
@deepak_four it is not set bits that is equal to logN.
number of bits in a number is floor(logN)+1.sir has told LogN in terms of time complexity so just take logN for time complexity not this
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.