3 ms·
Oh, agree that for arbitrary large or non integer inputs it might not work. But elsethread jepler has shown a solution off Hacker's Delight which which simply
by gpderetta 7y ago
Oh, agree that for arbitrary large or non integer inputs it might not work. But elsethread jepler has shown a solution off Hacker's Delight which which simply multiplies the index of the most significant bit with a magic constant.
- MauranKilom 7y ago> But elsethread jepler has shown a solution off Hacker's Delight which which simply multiplies the index of the most significant bit with a magic constant. ...and then checks for and corrects the potential off-by-one thus incurred.
- slavik81 7y agoWhen N is fixed, all algorithms become O(1). That's why they appear the same. If you do these calculations by hand, the complexity will be more obvious because each operation will be smaller.