Quantcast
Channel: Bits counting algorithm (Brian Kernighan) in an integer time complexity - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by The_Sympathizer for Bits counting algorithm (Brian Kernighan) in an integer time complexity

$
0
0

There are floor(lg(N)) + 1 significant bits in N -- that's a base-2 logarithm. The number of 1 bits in n is at most this. So the time will have asymptotic upper bound O(lg(N)) = O(log(N)).


Viewing all articles
Browse latest Browse all 4

Trending Articles