searches.double_linear_search¶
Functions¶
|
Iterate through the array from both sides to find the index of search_item. |
Module Contents¶
- searches.double_linear_search.double_linear_search(array: list[int], search_item: int) int ¶
Iterate through the array from both sides to find the index of search_item.
- Parameters:
array – the array to be searched
search_item – the item to be searched
:return the index of search_item, if search_item is in array, else -1
Examples: >>> double_linear_search([1, 5, 5, 10], 1) 0 >>> double_linear_search([1, 5, 5, 10], 5) 1 >>> double_linear_search([1, 5, 5, 10], 100) -1 >>> double_linear_search([1, 5, 5, 10], 10) 3