mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-01 00:41:09 +00:00
Merge pull request #246 from antfitch/antfitch-patch-1
Fixed recursion error in binary_search_by_recursion
This commit is contained in:
commit
4085de4fae
|
@ -110,6 +110,9 @@ def binary_search_by_recursion(sorted_collection, item, left, right):
|
||||||
>>> binary_search_std_lib([0, 5, 7, 10, 15], 6)
|
>>> binary_search_std_lib([0, 5, 7, 10, 15], 6)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
if (right < left):
|
||||||
|
return None
|
||||||
|
|
||||||
midpoint = left + (right - left) // 2
|
midpoint = left + (right - left) // 2
|
||||||
|
|
||||||
if sorted_collection[midpoint] == item:
|
if sorted_collection[midpoint] == item:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user