Fix bucket_sort.

This commit is contained in:
krahets
2023-05-15 19:54:07 +08:00
parent bae8298c8a
commit f35020b335
4 changed files with 4 additions and 4 deletions

View File

@@ -17,7 +17,7 @@ func bucketSort(nums []float64) {
// 1. 将数组元素分配到各个桶中
for _, num := range nums {
// 输入数据范围 [0, 1),使用 num * k 映射到索引范围 [0, k-1]
i := int(num) * k
i := int(num * float64(k))
// 将 num 添加进桶 i
buckets[i] = append(buckets[i], num)
}