Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
16 lines (15 sloc) 321 Bytes
def binary_search_iterative(collection, value)
low = 0
high = (collection.length - 1)
while low <= high
mid = (low + high) / 2
if collection[mid] > value
high = mid - 1
elsif collection[mid] < value
low = mid + 1
else
return collection[mid]
end
end
return "not found"
end
You can’t perform that action at this time.