binary search with bitwise is excellent.
It will guarantee searching in log32 = 5 lookups.
Great!

On Jul 24, 5:00 pm, Amir hossein Shahriari
<amir.hossein.shahri...@gmail.com> wrote:
> 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to