希望大家在看代码之前先去看看图解,我在这里就只实现了代码
也可以在底下留言,我会慢慢讲解的
public class bucketsort {
public static void bucket_test1(int[] arr){
int[] bucket = new int[findmax(arr)+1];//建立一个超级大的数组(桶)
for(int i =0;i max)
max = arr[i];
}
return max;
}
public static void main(String[] args) {
int[] arr ={9,8,7,6,5,4,3,2,1,9,8,7,6,5,4,3,2,1};
// bucket_test2(arr);
bucket(arr);
System.out.println(Arrays.toString(arr));
}
}



