Create a gist now

Instantly share code, notes, and snippets.

def search(arr, t)
min = 0
max = arr.count -1
mid = (max-min)/2
if arr.count == 0 || (arr.count == 1 && arr[0] != t)
return -1
elsif t <= arr[mid]
return search(arr[0..mid], t)
else
return mid + search(arr[mid..-1], t)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment