posted 12 years ago
I think you got the min and max part of the algorithm wrong. They are meant to be the search boundaries. At the moment you are looping through the entire array twice per call; that goes completely against the entire point of the binary search.
Here's a modified version of your code: