Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dc4282f

Browse files
authored
Update bin_search.py
Fix the division to yield integer for index
1 parent 1b3f61f commit dc4282f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Chapter09/bin_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def binary_search(ordered_list, term):
88
index_of_last_element = size_of_list
99

1010
while index_of_first_element <= index_of_last_element:
11-
mid_point = (index_of_first_element + index_of_last_element)/2
11+
mid_point = (index_of_first_element + index_of_last_element) // 2
1212

1313
if ordered_list[mid_point] == term:
1414
return mid_point

0 commit comments

Comments
 (0)