File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
src/main/java/com/thealgorithms/searches Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ public static int jumpSearch(int[] arr, int target) {
25
25
while (prev < n && arr [Math .min (step , n ) - 1 ] < target ) {
26
26
prev = step ;
27
27
step += (int ) Math .floor (Math .sqrt (n ));
28
-
29
28
}
30
29
31
30
for (int i = prev ; i < Math .min (step , n ); i ++) {
@@ -36,4 +35,19 @@ public static int jumpSearch(int[] arr, int target) {
36
35
37
36
return -1 ;
38
37
}
38
+
39
+ /**
40
+ * Wrapper method to support Integer[] for testing purposes.
41
+ *
42
+ * @param arr array of Integers
43
+ * @param target target value
44
+ * @return index if found, else -1
45
+ */
46
+ public static int find (Integer [] arr , Integer target ) {
47
+ int [] array = new int [arr .length ];
48
+ for (int i = 0 ; i < arr .length ; i ++) {
49
+ array [i ] = arr [i ];
50
+ }
51
+ return jumpSearch (array , target );
52
+ }
39
53
}
You can’t perform that action at this time.
0 commit comments