Algorithms icon indicating copy to clipboard operation
Algorithms copied to clipboard

Bucket sort bug fix

Open TianyiShi2001 opened this issue 4 years ago • 0 comments
trafficstars

In the current implementation all elements will be placed into bucket 0 (ar[i] - minValue is always less than M, which is maxValue - minValue + 1, so ar[i] - minValue) / M must be 0) (see commit https://github.com/williamfiset/Algorithms/commit/be4b0a9533de73461261e9aa6aca35b9e0c50f41 )

To place into different buckets the bucket index should be calculated as numBuckets * (ar[i] - minValue) / M

TianyiShi2001 avatar Jun 22 '21 09:06 TianyiShi2001