Page 1 of 1
NXC: ArraySort algorithm?
Posted: 20 Jan 2013, 16:32
by HaWe
hey,
what is the algorithm used by ArraySort?
Bubble Sort?
Insertion Sort?
Merge Sort?
Quick Sort?
Re: NXC: ArraySort algorithm?
Posted: 21 Jan 2013, 17:09
by afanofosc
http://en.wikipedia.org/wiki/Shellsort
Code: Select all
void shell_sort_flt(float* A, UWORD size)
{
UWORD i, j, increment;
float temp;
increment = size / 2;
while (increment > 0) {
for (i = increment; i < size; i++) {
j = i;
temp = A[i];
while ((j >= increment) && (A[j-increment] > temp)) {
A[j] = A[j - increment];
j = j - increment;
}
A[j] = temp;
}
if (increment == 2)
increment = 1;
else
increment = (UWORD)((float)increment / (float)2.2);
}
}
John Hansen
Re: NXC: ArraySort algorithm?
Posted: 21 Jan 2013, 19:16
by HaWe
aha,
thank you!