Skip to content

fix(searches): add null safety and Comparable consistency to JumpSearch - #7653

Merged
DenizAltunkapan merged 2 commits into
TheAlgorithms:masterfrom
hardikkaurani:fix/jump-search-null-safety
Oct 25, 2026
Merged

DenizAltunkapan merged 2 commits into
TheAlgorithms:masterfrom
hardikkaurani:fix/jump-search-null-safety

Conversation

@hardikkaurani

Copy link
Copy Markdown
Contributor
  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new algorithms include a corresponding test class that validates their functionality.
  • All new code is formatted with \clang-format -i --style=file path/to/your/file.java\

Description

This pull request improves \JumpSearch:

  1. Null and Empty Input Safety: Added guard against
    ull\ array, empty array, and
    ull\ key returning -1\ instead of throwing \NullPointerException.
  2. Comparable Contract Consistency: Replaced \�rray[i].equals(key)\ with \key.compareTo(array[i]) == 0\ for proper \Comparable\ contract semantics.
  3. Class Final Modifier: Marked \public final class JumpSearch implements SearchAlgorithm\ consistent with utility implementations in \com.thealgorithms.searches.
  4. Expanded Tests: Added unit tests for null array, null key, single-element array with absent target, duplicate elements, and string arrays.

CC: @alxkm for review

Copilot AI balanced review requested due to automatic review settings October 22, 2026 06:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Hi @alxkm, opened this PR to add null safety guards (returning -1 on null/empty inputs) and ensure Comparable contract consistency (\key.compareTo(array[i]) == 0) in \JumpSearch, matching the conventions in other search algorithms in this package. Whenever convenient, please take a look! Thanks!

@codecov-commenter

codecov-commenter commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.19%. Comparing base (2dd1a0a) to head (50d2a5e).

Files with missing lines Patch % Lines
...in/java/com/thealgorithms/searches/JumpSearch.java 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7653      +/-   ##
============================================
- Coverage     82.22%   82.19%   -0.03%     
  Complexity     8391     8391              
============================================
  Files           843      843              
  Lines         26125    26127       +2     
  Branches       5096     5096              
============================================
- Hits          21480    21476       -4     
- Misses         3857     3858       +1     
- Partials        788      793       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DenizAltunkapan

Copy link
Copy Markdown
Member

@hardikkaurani thanks!

@DenizAltunkapan
DenizAltunkapan enabled auto-merge (squash) October 25, 2026 18:33
@DenizAltunkapan
DenizAltunkapan merged commit 976cebc into TheAlgorithms:master Oct 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants