Skip to content

Commit 18907e4

Browse files
committed
fix type error (except an int) in jumpmp_search line 7.
1 parent fecba12 commit 18907e4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

searches/jump_search.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import math
33
def jump_search(arr, x):
44
n = len(arr)
5-
step = math.floor(math.sqrt(n))
5+
step = int(math.floor(math.sqrt(n)))
66
prev = 0
77
while arr[min(step, n)-1] < x:
88
prev = step
9-
step += math.floor(math.sqrt(n))
9+
step += int(math.floor(math.sqrt(n)))
1010
if prev >= n:
1111
return -1
1212

@@ -23,4 +23,4 @@ def jump_search(arr, x):
2323
arr = [ 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]
2424
x = 55
2525
index = jump_search(arr, x)
26-
print("\nNumber " + str(x) +" is at index " + str(index));
26+
print("\nNumber " + str(x) +" is at index " + str(index));

0 commit comments

Comments
 (0)