Knuth version of binary search