did you try to execute the algorithm with an array that has only 1 element. E.g. A=[1]. If you search for the value 1 it'll give "false" or in this case "-1" because low == high and the loop body is never entered despite the value 1 being part of the array. It might be faster but will fail to deliver the right answer for at least one cases.