We can explain you the algorithm or help you fix your code.
DEAL! I know this forum got it reasons and it really don't matter. What all you guys done for me I am a better C++ coder. This subject is for expert C++sors really. My only goal is Vector, MAP and it, as my hobby and work. I got enough docs to read until QUANTUM arrive, and have. I just need to know what the C++ algorithm looks like. I am a expert assembler for over 12 years just like you guys are expert C++sor. All we got to do is look at an algorithm, clean it up, pop it in, add some code or a debugger so you can see how it works, than clock it for comparison to others, and not a darn thing else. It just takes me longer for C++ but I will master it the day it all kick-in. I had all of this code on my machine from months ago. Know some JAVA, google and read into this forum or few if you really want to learn C++ fast. I had it all the time and forgot about em. I got over a 60,000 examples in ASM that I use, repaired or wrote so I care nothing of homework. Final noobish question:: Is once or both of these the this the real McCoy? I am in no rush. Need the full source? Let just me know. Btw; 10 out of 10 this site disable the code above. Don't ask me to prove it. I also have it on the net elsewhere and the same code works! Want the link, PM me.
1)
Code:
void bucketSort(int *inArr, int arrSize, int variance){
int *bucket = (int*)malloc(sizeof(int) * variance);
// Initialize all bucket nodes to have a count of 0
memset(bucket, 0, sizeof(int) * variance);
// Throw the count of each node into the bucket
for (int i = 0; i < arrSize; i++){
bucket[inArr[i]]++;
}
// We'll fill the new array with whatever is in the bucket
int newArrayPosition = 0;
for (int x = 0; x < variance; x++){
for (int j = 0; j < bucket[x]; j++){
inArr[j + newArrayPosition] = x;
}
newArrayPosition += bucket[x];
}
free(bucket);
}
2)
Code:
void BucketSort (unsigned int a [], unsigned int n)
{
int buckets [m];
for (unsigned int j = 0; j < m; ++j)
buckets [j] = 0;
for (unsigned int i = 0; i < n; ++i)
++buckets [a [i]];
for (unsigned int i = 0, j = 0; j < m; ++j)
for (unsigned int k = buckets [j]; k > 0; --k)
a [i++] = j;
}
I don't plan to move on, I plan to go forward.