This commit is contained in:
krahets
2024-04-09 20:43:40 +08:00
parent d8caf02e9e
commit a6adc8e20a
48 changed files with 1599 additions and 571 deletions
+2 -2
View File
@@ -395,9 +395,9 @@ comments: true
fun bucketSort(nums: FloatArray) {
// 初始化 k = n/2 个桶,预期向每个桶分配 2 个元素
val k = nums.size / 2
val buckets = ArrayList<ArrayList<Float>>()
val buckets = mutableListOf<MutableList<Float>>()
for (i in 0..<k) {
buckets.add(ArrayList())
buckets.add(mutableListOf())
}
// 1. 将数组元素分配到各个桶中
for (num in nums) {