Skip to content

Add Jump Search algorithm in Java #6407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
Fix: prevent instantiation of utility class JumpSearch
  • Loading branch information
Fahham29 committed Jul 18, 2025
commit 2994ade8acd529fcc94d2583a7b60f549bf28a35
19 changes: 5 additions & 14 deletions src/main/java/com/thealgorithms/searches/JumpSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
*/
public class JumpSearch {

/**
* Performs jump search on a sorted array.
*
* @param arr sorted array of integers
* @param target the element to find
* @return index of target if found, else -1
*/
// Prevent instantiation
private JumpSearch() {
throw new UnsupportedOperationException("Utility class");
}

public static int jumpSearch(int[] arr, int target) {
int n = arr.length;
int step = (int) Math.floor(Math.sqrt(n));
Expand All @@ -36,13 +34,6 @@ public static int jumpSearch(int[] arr, int target) {
return -1;
}

/**
* Wrapper method to support Integer[] for testing purposes.
*
* @param arr array of Integers
* @param target target value
* @return index if found, else -1
*/
public static int find(Integer[] arr, Integer target) {
int[] array = new int[arr.length];
for (int i = 0; i < arr.length; i++) {
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy