mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
Enable ruff PLR5501 rule (#11332)
* Enable ruff PLR5501 rule * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -33,18 +33,16 @@ def interpolation_search(sorted_collection, item):
|
||||
current_item = sorted_collection[point]
|
||||
if current_item == item:
|
||||
return point
|
||||
elif point < left:
|
||||
right = left
|
||||
left = point
|
||||
elif point > right:
|
||||
left = right
|
||||
right = point
|
||||
elif item < current_item:
|
||||
right = point - 1
|
||||
else:
|
||||
if point < left:
|
||||
right = left
|
||||
left = point
|
||||
elif point > right:
|
||||
left = right
|
||||
right = point
|
||||
else:
|
||||
if item < current_item:
|
||||
right = point - 1
|
||||
else:
|
||||
left = point + 1
|
||||
left = point + 1
|
||||
return None
|
||||
|
||||
|
||||
@ -79,15 +77,14 @@ def interpolation_search_by_recursion(sorted_collection, item, left, right):
|
||||
return interpolation_search_by_recursion(sorted_collection, item, point, left)
|
||||
elif point > right:
|
||||
return interpolation_search_by_recursion(sorted_collection, item, right, left)
|
||||
elif sorted_collection[point] > item:
|
||||
return interpolation_search_by_recursion(
|
||||
sorted_collection, item, left, point - 1
|
||||
)
|
||||
else:
|
||||
if sorted_collection[point] > item:
|
||||
return interpolation_search_by_recursion(
|
||||
sorted_collection, item, left, point - 1
|
||||
)
|
||||
else:
|
||||
return interpolation_search_by_recursion(
|
||||
sorted_collection, item, point + 1, right
|
||||
)
|
||||
return interpolation_search_by_recursion(
|
||||
sorted_collection, item, point + 1, right
|
||||
)
|
||||
|
||||
|
||||
def __assert_sorted(collection):
|
||||
|
Reference in New Issue
Block a user