def bin_search(data_set, val):
    low = 0
    high = len(data_set) - 1

    while low <= high:
        mid = (low + high) //2
        if data_set[mid] == val:
            return mid

        elif data_set[mid] <  val:
            low = mid + 1
        else:
            high = mid - 1

    return

 

def bin_search(data_set, val):
low = 0
high = len(data_set) - 1

while low <= high:
mid = (low + high) //2
if data_set[mid] == val:
return mid

elif data_set[mid] < val:
low = mid + 1
else:
high = mid - 1

return

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
  • 2022-12-23
  • 2021-03-30
猜你喜欢
  • 2021-10-20
  • 2021-06-14
  • 2021-09-04
  • 2022-12-23
  • 2021-12-21
  • 2021-05-15
相关资源
相似解决方案