Skip to content

Commit e4380c7

Browse files
Add exponential_search doctest for empty array edge case
This doctest demonstrates that exponential_search correctly handles empty arrays by returning -1.
1 parent a051ab5 commit e4380c7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

searches/exponential_search.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ def exponential_search(sorted_collection: list[int], item: int) -> int:
8181
1
8282
>>> exponential_search([0, 5, 7, 10, 15], 6)
8383
-1
84+
85+
>>> exponential_search([], 1) # Empty array edge case
86+
-1
8487
"""
8588
if list(sorted_collection) != sorted(sorted_collection):
8689
raise ValueError("sorted_collection must be sorted in ascending order")

0 commit comments

Comments
 (0)