Skip to content

double_linear_search algorithm #2161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 4, 2020
Prev Previous commit
Next Next commit
Update double_linear_search.py
  • Loading branch information
reinhold-b authored Jul 2, 2020
commit 53fa9de85232b69db5e1edf537f1cec0d71809c6
15 changes: 7 additions & 8 deletions searches/double_linear_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
def double_linear_search(array, x):
""":param array: the array to be searched
:param x: the value to be searched (float, int or string)
:returns index of x, if x is in array, else -1
:returns index of x, if x is in array, else -1

Examples:

>>> double_linear_search([1, 2, 5, 5, 20], 2)
>>>double_linear_search([1, 5, 5, 10], 5)
1

>>> double_linear_search([1, 2, 5, 5, 20], 5)
2

>>> double_linear_search([1, 2, 5, 5, 20], 100)
>>>double_linear_search([1, 5, 5, 10], 100)
-1
"""

>>>double_linear_search([1, 5, 5, 10], 10)
3
"""

# define the start and end index of the given array
start_ind, end_ind = 0, len(array) - 1
Expand Down Expand Up @@ -57,4 +57,3 @@ def double_linear_search(array, x):
# print(array)

print(double_linear_search(array, x))
# output: 40