function pos = binarySearch(array, value)
left = 1;
right = length(array);
while left <= right
   mid = left + round((right - left)/2);
   if array(mid) == value
      pos = mid;
      return
   elseif array(mid) < value
      left = mid + 1;
   else
      right = mid - 1;
   end
end
pos = -1;
end