Back to course home
0% completed
Vote For New Content
Any reason why we can’t just do numberOfBits = int(math.floor(math.log2(number))...
Joey
Aug 4, 2022
Any reason why we can’t just do
numberOfBits = int(math.floor(math.log2(number)) + 1)
?
What would be the impact of complexity in this case? Since we’re not dealing with an array but number of bits
1
0
Comments
Comments
J
Joey 3 years ago
Would this give O(1) time complexity?
M
Mike Xu3 years ago
Yes it would be O(1) time complexity still since you are just running a log operation on 1 number.
On this page