Skip to content

Conversation

@GziXnine
Copy link
Contributor

@GziXnine GziXnine commented Jan 9, 2026

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

Summary

Adds Tournament Sort (winner-tree) to the sorts package.

What changed

  • Added TournamentSort implementation using a winner tree (stores indices and updates the path to the root after each extraction).
  • Added TournamentSortTest integrating with the shared SortingAlgorithmTest suite.

Why this approach

Compared to a naive “rebuild the tree every iteration” or “remove + compact with nulls” approach, this version:

  • Keeps extraction at O(log n) by updating only the affected path in the tree.
  • Avoids null compaction / repeated scans that can push runtime toward O(n^2).
  • Matches repository conventions: no main method, in-place output array (sorts the input array), and includes Javadoc + test.

Closes #6631

@codecov-commenter
Copy link

codecov-commenter commented Jan 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.00%. Comparing base (fe6066b) to head (5e725b6).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7201      +/-   ##
============================================
+ Coverage     78.98%   79.00%   +0.02%     
- Complexity     6907     6920      +13     
============================================
  Files           775      776       +1     
  Lines         22822    22852      +30     
  Branches       4482     4489       +7     
============================================
+ Hits          18025    18054      +29     
  Misses         4077     4077              
- Partials        720      721       +1     

☔ View full report in Codecov by Sentry.
📢 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.

@GziXnine
Copy link
Contributor Author

Hi maintainers

Just a quick follow-up since I noticed recent activity on the repository.
This PR is ready for review, all checks are passing and tests are included.

If there’s anything you’d like me to adjust or improve, I’m happy to update it right away.
Thanks again for your time and for reviewing my previous SmoothSort contribution

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.

[FEATURE REQUEST] Add TournamentSort Sorting Algorithm

3 participants