diff --git a/searches/binary_search.py b/searches/binary_search.py index 93bf189cc08f..7df45883c09a 100644 --- a/searches/binary_search.py +++ b/searches/binary_search.py @@ -110,6 +110,9 @@ def binary_search_by_recursion(sorted_collection, item, left, right): >>> binary_search_std_lib([0, 5, 7, 10, 15], 6) """ + if (right < left): + return None + midpoint = left + (right - left) // 2 if sorted_collection[midpoint] == item: