Related articles |
---|
[49 earlier articles] |
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? pardo@cs.washington.edu (1996-03-25) |
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? mgrice@iastate.edu (1996-03-27) |
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? sberg@camtronics.com (1996-03-31) |
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? nather@astro.as.utexas.edu (R. Edward Nather) (1996-04-02) |
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? ok@cs.rmit.edu.au (1996-04-02) |
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? sberg@camtronics.com (1996-04-06) |
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? ok@cs.rmit.edu.au (1996-04-10) |
From: | ok@cs.rmit.edu.au (Richard A. O'Keefe) |
Newsgroups: | comp.arch,comp.compilers |
Date: | 10 Apr 1996 08:33:07 -0400 |
Organization: | Comp Sci, RMIT, Melbourne, Australia |
References: | 96-03-006 96-04-019 96-04-029 |
Keywords: | optimize |
sberg@camtronics.com (Scott A. Berg) writes:
>So these are 32 or even 64 bit integers or even floating point
>numbers, randomly and uniformly spread across the entire range. How
>many buckets is this? Or perhaps you're using different names for
>sorts than I'm used to seeing.
The idea of bucket sort is
(1) In one pass using 3N/2 comparisons, find Min and Max.
(2) Allocate N buckets (or some other number reasonably close to N)
(3) In one pass move each element X[i] to bucket number
floor( (X[i]-Min)/(Max-Min) * N )
(4) Sort each bucket using some other algorithm; the worst case bucket
size is N, so if you use an O(NlgN) algorithm on the buckets, the
worst overall cost is O(NlgN)
(5) Concatenate the buckets.
If the input is random and uniformly distributed, that's a very _good_
case for bucket sort, and you get O(N) time. If the numbers are
spread across the _entire_ range, you have to be a bit clever in step
(3) to avoid overflow, but it's still not enormously complicated.
>Alas, so have I. Perhaps we should spend less time attempting to
>create the ultimate compiler and more time teaching practitioners how
>to use what they've got! Besides, if you see these sort of problems
>with the applications, why do you think the compilers are any better?
I don't. Compilers are notorious for running into extremely hard
problems. I've heard of one compiler spending a week on one 200-line
function. I have more reasons than one for compiling my code with
every compiler I have available. (I compile Fortran with f77 and f2c;
I compile C with cc, gcc, and lcc; and so on.)
--
Richard A. O'Keefe; http://www.cs.rmit.edu.au/~ok; RMIT Comp.Sci.
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.