I have done experiments with quick and selection sorts. Their sources are attached, their results follow below.
The next table shows the size of code for sorting routines and amount of zp memory required.
Code:
size zp
quick 271 12(min=6)
shell 196 6
selection 118 6
The next tables show the speed of the routines in clock cycles for 4096 and 8063 elements. I use Chromatix's 8 byte data structure for all cases.
Code:
4096 quick shell selection
random (gcc) 6,945,023 14,841,052 546,689,912
random (gen) 7,078,469 14,633,170 546,689,967
qs-slow (16B) 11,780,993 11,767,274 546,474,774
descending 3,405,405 8,509,600 592,522,281
ascending 2,833,756 3,219,746 546,384,937
constant 9,610,629 3,219,746 546,384,937
8063 quick shell selection
random (gcc) 14,658,383 33,545,066 2,117,270,138
random (gen) 14,979,654 32,611,660 2,117,259,303
qs-slow (16B) 23,994,141 25,221,514 2,116,756,702
descending 7,084,521 19,542,402 2,295,383,997
ascending 5,960,625 6,614,042 2,116,601,085
constant 18,379,125 6,614,042 2,116,601,085
The quicksort routine uses 16 as a stack limit. Filling type 'qs-slow' usually kills quicksort with large enough data. This filling uses the next algorithm.
Code:
mem[0] = 1;
mem[1] = 3;
mem[2] = 5;
mem[3] = 0;
mem[4] = 2;
mem[5] = 4;
for (int i = 3; i < SIZE*2; i++) {
mem[2*i] = mem[i];
mem[2*i + 1] = mem[2*i - 1] + 2;
mem[i] = 2*i + 1;
}
So it is also interesting to get the 6800 variants for quicksort and selectionsort.
Attachment:
sort-quick-selection.zip [2.14 KiB]
Downloaded 76 times