3 ms·
Just another wrong implementation of Binary Search, http://algorithms.openmymind.net/search/binarysearch http://algorithms.openmymind.net/search/binarysearch, s
by tszming 16y ago
Just another wrong implementation of Binary Search, http://algorithms.openmymind.net/search/binarysearch http://algorithms.openmymind.net/search/binarysearch, see this: http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html http://googleresearch.blogspot.com/2006/06/extra-extra-read-...
- jws 16y agoYes, but if you are using binary search on a list with 2^52 elements…
- maggit 16y agoDid you mean 2^32? That I could understand. 2^52 looks entirely random to me.
- tsewlliw 16y agothe implementation on the site is in JavaScript, where everything is 64-bit floats. I'd guess 52 of those bits are mantissa.
- jws 16y agoAlert! There is an error on the internet. The source I used for Javascript mantissa size was wrong. It said 53 bits, I knocked one off to avoid the addition overflow, but that source must have counted the sign bit. IEEE doubles only have a 52 bit mantissa, so you need to keep that array under 2^51 elements. Call it 2 quadrillion to be safe.
- baddox 16y agoDoes the author ever claim what language the code is in? Sure, it looks like JavaScript, but he could easily have just borrowed JavaScript's function syntax (which is easily readable to anyone who's used virtually any imperative programming language) for his pseudocode. The potential "bug" you pointed out has nothing to do with the algorithm being taught, and is an implementation detail that's irrelevant for this application.