3 ms·
I wrote a test program in C, using the same functions as OP wrote. Compiled with maximum optimizations, the binarysearch() was 33% faster over the more complic
by deletes 13y ago
I wrote a test program in C, using the same functions as OP wrote.
Compiled with maximum optimizations, the binarysearch() was 33% faster over the more complicated dualPivotBinarysearch(). I tested every element of the array, with array sizes from 100000 to 10000000 elements in steps of 100000.
An different iterative version of binary search was 6.5% faster than binarysearch() using the same test.