Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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)
return mid + search(arr[mid..-1], t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment