java实现桶排序算法

前面我们详细讲解了桶排序算法,现在我们用java代码实现以下

package ttt;

public class BucketSort {
    public static int[] BucketSort(int[] theArray) {
    	int []firstArray = new int[100];
    	int []lastArray = new int[theArray.length];
    	int m = 0;
    	for(int i=0; i0) {
        		for(int k=0; k

执行结果:

之前的排序:10 1 18 30 23 12 7 5 18 17 桶排序:1 5 7 10 12 17 18 18 23 30 

符合预期

你可能感兴趣的:(算法与数据结构)