we can use a binary search to search for the bit in O(logn)
the search would look like this:
we first compute
n & 0xFFFF0000 (which is 16 1s and 16 0s)
if the result is 0 then the left most 1 is in the 16 less significant bits
else it is in the 16 more significant bits
then we can continue this way
for example if the result in the first step is zero the next step would be
to compute n & 0x0000FF00 to find whether the leftmost set bit is in the 8
less significant bits or not

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to