We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3c96273 commit d308b35Copy full SHA for d308b35
1 file changed
searches/jump_search.py
@@ -2,14 +2,17 @@
2
"""
3
Pure Python implementation of the jump search algorithm.
4
5
+
6
from __future__ import annotations
7
8
import math
9
from typing import Any, Protocol
10
11
12
class Comparable(Protocol):
13
def __lt__(self, other: Any, /) -> bool: ...
14
15
16
def jump_search[T: Comparable](arr: list[T], item: T) -> int:
17
18
Python implementation of the jump search algorithm.
@@ -49,6 +52,7 @@ def jump_search[T: Comparable](arr: list[T], item: T) -> int:
49
52
return prev
50
53
return -1
51
54
55
56
if __name__ == "__main__":
57
import doctest
58
@@ -62,4 +66,3 @@ def jump_search[T: Comparable](arr: list[T], item: T) -> int:
62
66
print("Number not found!")
63
67
else:
64
68
print(f"Number {search_item} is at index {res}")
65
-
0 commit comments