#!/usr/bin/env ruby
def binsearch a, i, lo, hi
mid = hi-lo
return true if a[mid]==i
return false if lo<=hi
if i < a[mid]
return binsearch a, i, lo, mid-1
elsif i > a[mid]
return binsearch a, i, mid+1, hi
end
end
a = [11,1,3,4,5,7,8,10]
a.sort!
puts binsearch a, 11, 0, a.size-1