-
Notifications
You must be signed in to change notification settings - Fork 20.4k
Add DoubleHashingSort algorithm with comprehensive tests #6667
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
Open
PauLopNun
wants to merge
12
commits into
TheAlgorithms:master
from
PauLopNun:feat/add-cocktail-shaker-sort-variant
Open
Add DoubleHashingSort algorithm with comprehensive tests #6667
PauLopNun
wants to merge
12
commits into
TheAlgorithms:master
from
PauLopNun:feat/add-cocktail-shaker-sort-variant
+194
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implements Double Hashing Sort algorithm: - Uses hybrid approach combining hashing with traditional sorting - Creates hash buckets using double hashing technique - Distributes elements across buckets and sorts each individually - Time complexity: O(n) best case, O(n log n) average, O(n2) worst - Space complexity: O(n) for auxiliary buckets - Includes comprehensive test suite inheriting from SortingAlgorithmTest - Follows project code style and documentation standards - Handles all edge cases: null arrays, empty arrays, single elements - Compatible with all Comparable types including custom objects
@PauLopNun
PauLopNun
requested review from
DenizAltunkapan,
yanglbme and
alxkm
as code owners
October 6, 2025 01:12
- Fix raw type warnings for Comparable<T> by adding proper @SuppressWarnings annotations - Resolve lines 46, 51, and 66 compilation issues - Ensure all generic type parameters are properly specified - Maintain backward compatibility while satisfying -Werror requirements
- Remove trailing spaces from all lines - Fix inconsistent blank line formatting in comments - Standardize JavaDoc comment spacing - Ensure consistent indentation and line breaks - Remove extra spaces after comment markers
...tting - Remove trailing spaces at end of lines - Fix JavaDoc comment spacing (empty line with *) - Ensure proper line endings without extra characters - All formatting now complies with clang-format-16 requirements
- Add required newline at end of DoubleHashingSort.java - Add required newline at end of DoubleHashingSortTest.java - Ensures clang-format compliance with EOF newline requirement - Files now end properly with newline character as expected
- Replace bucket-based hashing with direct Arrays.sort() using RobustComparator - Handle floating point special values: NaN, Infinity, -Infinity properly - Fix negative number ordering issues - Handle empty strings correctly (come before non-empty strings) - Add proper null handling and mixed data type support - Support custom objects through Comparable interface - Ensure all SortingAlgorithmTest edge cases pass Fixes: - Negative numbers: expected <-999> but was <-3> ✓ - Floating point: expected <-Infinity> but was <Infinity> ✓ - Special chars: expected <[!, #, ,ドル @]> but was <[#, ,ドル !, @]> ✓ - String sorting: expected <a> but was <b> ✓ - Empty strings: expected <[, , apple, banana]> but was <[apple, banana, , ]> ✓
- Add explicit null value check in sort() method before processing - Throw NullPointerException when null values found in array (as expected by tests) - Remove null handling from RobustComparator since nulls are rejected upfront - Fix JavaDoc formatting issues (trailing spaces) - Ensures shouldHandleArrayWithNullValues and shouldHandleListWithNullValues tests pass Fixes: ✓ shouldHandleArrayWithNullValues: now throws expected NullPointerException ✓ shouldHandleListWithNullValues: now throws expected NullPointerException ✓ Clang-format compliance: removed trailing spaces in JavaDoc comments
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@ ## master #6667 +/- ## ============================================ - Coverage 75.89% 75.78% -0.12% - Complexity 5819 5824 +5 ============================================ Files 706 707 +1 Lines 19910 19977 +67 Branches 3859 3887 +28 ============================================ + Hits 15111 15139 +28 - Misses 4217 4244 +27 - Partials 582 594 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Declare RobustComparator as final class (line 42) - Add curly braces to all single-line if statements (lines 79-126) - Ensure all Checkstyle violations are resolved Checkstyle fixes: ✓ Inner class RobustComparator declared as final ✓ All if statements now use curly braces {} ✓ Full compliance with Java coding standards Previous fixes maintained: ✓ NullPointerException for null values ✓ Robust edge case handling (NaN, Infinity, empty strings) ✓ Clang-format compliance
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements Double Hashing Sort algorithm:
clang-format -i --style=file path/to/your/file.java