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 e94ff2c commit 3c96273Copy full SHA for 3c96273
1 file changed
searches/jump_search.py
@@ -5,14 +5,12 @@
5
from __future__ import annotations
6
7
import math
8
-from typing import Any, Protocol, TypeVar
+from typing import Any, Protocol
9
10
class Comparable(Protocol):
11
def __lt__(self, other: Any, /) -> bool: ...
12
13
-T = TypeVar("T", bound=Comparable)
14
-
15
-def jump_search(arr: list[T], item: T) -> int:
+def jump_search[T: Comparable](arr: list[T], item: T) -> int:
16
"""
17
Python implementation of the jump search algorithm.
18
Return the index if the `item` is found, otherwise return -1.
@@ -63,4 +61,5 @@ def jump_search(arr: list[T], item: T) -> int:
63
61
if res == -1:
64
62
print("Number not found!")
65
else:
66
- print(f"Number {search_item} is at index {res}")
+ print(f"Number {search_item} is at index {res}")
+
0 commit comments