Merge Sort - efficiancy crushed by recursion?

Started by
14 comments, last by Lutrosis 22 years, 3 months ago
The & 0xFF operation of the radix sort is the analog of the > operation in other sorts... no it''s not a comparison - but it''s not a fair comparison to measure a sort''s effectiveness solely by comparisons!

What are the reads/writes/compares for a merge sort?
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
quote:Original post by Beer Hunter
By that logic, you could say that adding or subtracting numbers is a comparison.

If you consider the disassembly they're not all that different...
Actually, I say that a subtraction is _more like a comparison than & is
a jnz instead of a mov


Edited by - Magmai Kai Holmlor on January 1, 2002 7:32:06 PM
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Hmmm. An array of 16 bins. I do declare, I''ve just overflowed. I meant, of course, 256 bins.
char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;}  /*** drpizza@battleaxe.net ***/
"The & 0xFF operation of the radix sort is the analog of the > operation in other sorts..."

What if you use a 32-bit radix?

"no it's not a comparison - but it's not a fair comparison to measure a sort's effectiveness solely by comparisons!"

Exactly!
But that doesn't mean you should hallucinate new meanings for "comparison". It means you should be measuring other things (reads and writes) as well!

How many reads and writes are used by the merge sort? I counted them and got 39,902,848 reads and the same number of writes <edit>for a 1,000,000 element array</edit>. For the record, 2 * 1,000,000 * log2 1,000,000 = 39,863,137 (rounded)... that's less than 0.1% off.

Edited by - Beer Hunter on January 2, 2002 7:12:14 PM
I said it was _like_ a comparison

Is it feasible to devise a radix sort for floating point types?
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
To an extent, yes.

http://codercorner.com/RadixSortRevisited.htm
char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;}  /*** drpizza@battleaxe.net ***/

This topic is closed to new replies.

Advertisement