arr
= [1, 7, 9, 11, 12, 12, 23, 43, 43, 43, 44, 45, 55, 65, 67, 67, 77, 89
]
def bin_search
(arr,key
):
low
= 0
high
= len
(arr
) - 1
while low
<= high:
mid
= (low + high
) // 2
if arr
[mid
] == key:
return mid
if key
< arr
[mid
]:
high
= mid - 1
else:
low
= mid + 1
return -1
print
(bin_search
(arr,11
))
输出: 3