3 ms·
Java's was broken till '06
by renewiltord 4y ago
Java's was broken till '06
- OnionBlender 4y agohttps://en.wikipedia.org/wiki/Binary_search_algorithm#Implementation_issues https://en.wikipedia.org/wiki/Binary_search_algorithm#Implem... People often do (L+R)/2 but that can overflow. Using L+(R-L)/2 avoids the overflow problem.
- nomel 4y agoAs someone who has a binary search in their interview question, I will claim that far more people run into the problem of trying to do midpoint/2 and midpoint*2, long before overflows.