快速算法(桶算法)

public class tongpaixu {


/**
* @param args
*/

private int[] buckets;
private int[] array;
public tongpaixu(int range,int[] array)
{
this.buckets=new int [range];
this.array=array;

}

public void sort(){
if(array!=null&&array.length>1)
{
for(int i=0;i {
buckets[array[i]]++;
}
}
}

public void print(){
//daoxushuchu
for(int i=buckets.length-1;i>=0;i--)
for(int j=0;j {
System.out.print(i);
}

}








public static void main(String[] args) {
// TODO Auto-generated method stub
test();
}
public static void test(){
int[] array={5,9,1,9,5,3,7,6,1};
tongpaixu t=new tongpaixu(11,array);
t.sort();
t.print();

}
}

你可能感兴趣的:(快速算法(桶算法))