better implementation for midpoint (#914)

This commit is contained in:
wuminbin
2019-06-24 18:11:07 +08:00
committed by John Law
parent a212efee5b
commit b7cff04574
2 changed files with 3 additions and 3 deletions

View File

@ -45,7 +45,7 @@ def binary_search(sorted_collection, item):
right = len(sorted_collection) - 1
while left <= right:
midpoint = (left + right) // 2
midpoint = left + (right - left) // 2
current_item = sorted_collection[midpoint]
if current_item == item:
return midpoint