Skip to content

Commit 4085de4

Browse files
authored
Merge pull request #246 from antfitch/antfitch-patch-1
Fixed recursion error in binary_search_by_recursion
2 parents c423419 + 53681f1 commit 4085de4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: searches/binary_search.py

+3
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ def binary_search_by_recursion(sorted_collection, item, left, right):
110110
>>> binary_search_std_lib([0, 5, 7, 10, 15], 6)
111111
112112
"""
113+
if (right < left):
114+
return None
115+
113116
midpoint = left + (right - left) // 2
114117

115118
if sorted_collection[midpoint] == item:

0 commit comments

Comments
 (0)