diff --git a/searches/exponential_search.py b/searches/exponential_search.py index ed09b14e101c..c275441e6bba 100644 --- a/searches/exponential_search.py +++ b/searches/exponential_search.py @@ -85,6 +85,9 @@ def exponential_search(sorted_collection: list[int], item: int) -> int: if list(sorted_collection) != sorted(sorted_collection): raise ValueError("sorted_collection must be sorted in ascending order") + if not sorted_collection: + return -1 + if sorted_collection[0] == item: return 0