binarySearch = function(A, value, low, high) if high < low then return null mid = floor((low + high) / 2) if A[mid] > value then return binarySearch(A, value, low, mid-1) if A[mid] < value then return binarySearch(A, value, mid+1, high) return mid end function