Skip to content

Add LibrarySort Implementation#7481

Open
Rosander0 wants to merge 1 commit into
TheAlgorithms:masterfrom
Rosander0:add-library-sort
Open

Add LibrarySort Implementation#7481
Rosander0 wants to merge 1 commit into
TheAlgorithms:masterfrom
Rosander0:add-library-sort

Conversation

@Rosander0

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

@codecov-commenter

codecov-commenter commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.85%. Comparing base (b3fcb12) to head (1427328).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7481      +/-   ##
============================================
+ Coverage     79.83%   79.85%   +0.01%     
- Complexity     7319     7328       +9     
============================================
  Files           805      806       +1     
  Lines         23785    23813      +28     
  Branches       4680     4687       +7     
============================================
+ Hits          18989    19015      +26     
  Misses         4036     4036              
- Partials        760      762       +2     

☔ 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.

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.

Pull request overview

Adds a new LibrarySort implementation under com.thealgorithms.sorts, along with a dedicated JUnit test class to validate basic behavior.

Changes:

  • Introduces LibrarySort sorting implementation and API (LibrarySort.sort(int[])).
  • Adds LibrarySortTest with basic correctness and input-validation tests (including null input).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/main/java/com/thealgorithms/sorts/LibrarySort.java Adds the new sorting implementation and its Javadoc/API.
src/test/java/com/thealgorithms/sorts/LibrarySortTest.java Adds unit tests covering common input shapes and null handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +4 to +9
/**
* Library Sort (also known as Gapped Insertion Sort) is a sorting algorithm
* that works like insertion sort but leaves gaps between elements to make
* future insertions faster.
* Time Complexity: O(n log n) average case
* Space Complexity: O(n)
Comment on lines +20 to +25
/**
* Sorts an array using the Library Sort algorithm.
*
* @param array the array to sort (must not be null)
* @return the sorted array
*/
*/
public static int[] sort(final int[] array) {
if (array == null) {
throw new IllegalArgumentException("Input array must not be null!");
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.

3 participants