Skip to content

Commit 2994ade

Browse files
author
Fahham29
committed
Fix: prevent instantiation of utility class JumpSearch
1 parent a7ba4ed commit 2994ade

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010
*/
1111
public class JumpSearch {
1212

13-
/**
14-
* Performs jump search on a sorted array.
15-
*
16-
* @param arr sorted array of integers
17-
* @param target the element to find
18-
* @return index of target if found, else -1
19-
*/
13+
// Prevent instantiation
14+
private JumpSearch() {
15+
throw new UnsupportedOperationException("Utility class");
16+
}
17+
2018
public static int jumpSearch(int[] arr, int target) {
2119
int n = arr.length;
2220
int step = (int) Math.floor(Math.sqrt(n));
@@ -36,13 +34,6 @@ public static int jumpSearch(int[] arr, int target) {
3634
return -1;
3735
}
3836

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-
*/
4637
public static int find(Integer[] arr, Integer target) {
4738
int[] array = new int[arr.length];
4839
for (int i = 0; i < arr.length; i++) {

0 commit comments

Comments
 (0)