This code takes O(logn) steps. The first solution proposed takes O(number of 1s)steps(which is less than O(logn) average case), the other approach is to some of the bit hacks in the link, there are methods to do that in O(loglogn) if n is fit within the word length of the processor though they are ugly.
--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
