File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 22"""
33Pure Python implementation of the jump search algorithm.
44"""
5+
56from __future__ import annotations
67
78import math
89from typing import Any , Protocol
910
11+
1012class Comparable (Protocol ):
1113 def __lt__ (self , other : Any , / ) -> bool : ...
1214
15+
1316def jump_search [T : Comparable ](arr : list [T ], item : T ) -> int :
1417 """
1518 Python implementation of the jump search algorithm.
@@ -49,6 +52,7 @@ def jump_search[T: Comparable](arr: list[T], item: T) -> int:
4952 return prev
5053 return - 1
5154
55+
5256if __name__ == "__main__" :
5357 import doctest
5458
@@ -62,4 +66,3 @@ def jump_search[T: Comparable](arr: list[T], item: T) -> int:
6266 print ("Number not found!" )
6367 else :
6468 print (f"Number { search_item } is at index { res } " )
65-
You can’t perform that action at this time.
0 commit comments