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) {
2525 while (prev < n && arr [Math .min (step , n ) - 1 ] < target ) {
2626 prev = step ;
2727 step += (int ) Math .floor (Math .sqrt (n ));
28-
2928 }
3029
3130 for (int i = prev ; i < Math .min (step , n ); i ++) {
@@ -36,4 +35,19 @@ public static int jumpSearch(int[] arr, int target) {
3635
3736 return -1 ;
3837 }
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+ }
3953}
You can’t perform that action at this time.
0 commit comments