PDA

View Full Version : bucket sort



nedata
دوشنبه 16 اردیبهشت 1387, 23:14 عصر
salam,man ye code peyda kardam toye internet ama nemidonam chetori azash estefade konam ke javab bede
age lotf konin komakam konin mamnoon misham

public class BucketSortAlgorithm {

public void sort(int[] a) throws Exception {
int m=128;
int[] count = new int[m];

for (int i=0;i<m;++i) count[i]=0;
for (int j=0;j<a.length;++j) {
++count[a[j]];

}
for (int i=0,j=0;i<m;++i)
for (; count[i]>0;--count[i]) {
a[j++]=i;

}
}

}