Skip to content

Commit 49a2d00

Browse files
author
Fahham29
committed
Fix formatting as per CI linter rules
1 parent 2c5717f commit 49a2d00

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/com/thealgorithms/searches/JumpSearch.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*
99
* Reference: https://en.wikipedia.org/wiki/Jump_search
1010
*/
11-
1211
public class JumpSearch {
1312

1413
public static int jumpSearch(int[] arr, int target) {
@@ -18,21 +17,23 @@ public static int jumpSearch(int[] arr, int target) {
1817

1918
while (arr[Math.min(step, n) - 1] < target) {
2019
prev = step;
21-
step += Math.floor(Math.sqrt(n));
22-
if (prev >= n)
20+
step += Math.floor(Math.sqrt(n));
21+
if (prev >= n) {
2322
return -1;
23+
}
2424
}
2525

2626
for (int i = prev; i < Math.min(step, n); i++) {
27-
if (arr[i] == target)
27+
if (arr[i] == target) {
2828
return i;
29+
}
2930
}
3031

3132
return -1;
3233
}
3334

3435
public static void main(String[] args) {
35-
int[] arr = { 1, 3, 5, 7, 9, 12, 17, 21, 25 };
36+
int[] arr = {1, 3, 5, 7, 9, 12, 17, 21, 25};
3637
int target = 12;
3738
int index = jumpSearch(arr, target);
3839
System.out.println("Found at index: " + index);

0 commit comments

Comments
 (0)