Skip to content

Commit 56a087d

Browse files
docs: add simple example and beginner-friendly explanation to JumpSearch
1 parent 4c7ac35 commit 56a087d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@
2727
* Result: Index = 4
2828
*
2929
* <p>
30+
* <b>Example (Simple):</b><br>
31+
* Input: arr = [2, 4, 6, 8, 10], key = 8<br>
32+
* Output: 3
33+
*
34+
* <p>
35+
* <b>Explanation (Easy):</b><br>
36+
* Instead of checking every element one by one, Jump Search skips elements
37+
* by jumping ahead fixed steps (√n). Once it finds a range where the element
38+
* might exist, it performs a linear search in that smaller block.
39+
*
40+
* <p>
3041
* <b>Time Complexity:</b><br>
3142
* - Best-case: O(1) - element found at first position<br>
3243
* - Average: O(√n) - optimal block size reduces jumps<br>

0 commit comments

Comments
 (0)