Skip to content
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

Issue #25: Implement Bucket Sort #36

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Brad-Edwards
Copy link
Collaborator

This PR implements the bucket sort algorithm with the following features:

  • Implementation for floating-point numbers in range [0, 1)
  • O(n + k) average case time complexity for uniform distribution
  • O(n + k) auxiliary space
  • Stable sorting (uses stable insertion sort for buckets)
  • Comprehensive documentation
  • Extensive unit tests covering:
    • Empty and single-element arrays
    • Already sorted arrays
    • Reverse sorted arrays
    • Random order arrays
    • Arrays with duplicates
    • Large arrays
    • Uniform distributions
    • Clustered values
    • Edge values (near 0 and 1)
    • Sparse distributions
    • Almost sorted arrays
    • Stability verification
    • Bucket index calculation
    • Individual bucket sorting

Key advantages:

  • Linear time complexity for uniform distribution
  • Works well with floating-point numbers
  • Can be parallelized easily
  • Good cache performance
  • Stable sorting

Limitations:

  • Requires uniformly distributed input for best performance
  • Not in-place sorting
  • Requires known input range [0, 1)
  • Uses extra space proportional to input size

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.

2 participants