生成一段java 桶排序算法
时间: 2023-03-12 18:35:02 浏览: 102
public static void bucketSort(int[] array, int maxNum) {
int[] buckets = new int[maxNum + 1];
for (int i = 0; i < array.length; i++) {
buckets[array[i]]++;
}
int k = 0;
for (int i = 0; i < buckets.length; i++) {
for (int j = 0; j < buckets[i]; j++) {
array[k++] = i;
}
}
}
阅读全文