Python Book, 11.4. Integer Square Root

#1

Is running a binary search on the interval from [0,k] really going to be faster than Math.floor(k ** 0.5)? This is a problem I would solve with a one liner in real code.

0 Likes

#2

Hi @hughesj919,

I think Math.floor(k ** 5) is probably faster because the underly implementation might be in C or C++. However, the purpose of this question is most likely to be assuming you need to implement this library for this language, so such one-liner would not work in interview :slight_smile:

0 Likes