[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Low-level vs. High-level programming (was My First Computer)
Matthew Russotto replied:
>In article <20030619155058.09031.00001455@mb-m18.aol.com>,
>Michael J. Mahon <mjmahon@aol.com> wrote:
>
>>This reminds me of an amusing story...
>>
>>Bubble sort was never the best algorithm to use for sorting, regardless
>>of data set size. However, he went on, bubble sort was apparently the
>>most "intuitive" sorting algorithm, the one "invented" by most people
>>when asked to write a sorting algorighm, and so it was the "best" for
>>teaching people _about_ sorting algorithms! ;-)
>
>Odd. I "invented" selection sort. And anyone who intuitively "invents" an
>n log n sort is a mutant, and will go far in the computing world :-)
>
>You could probably rig things to make bubble sort useful -- make it so
>data movement cost is proportional to the distance of the movement.
>
>>(BTW, for very small numbers of items, the "repeatedly pick lowest
>>and set it to infinity" algorithm ("pick and zot") is usually the fastest,
>>although it is exactly n**2.)
>
>I believe that's the selection sort by another name.
Hmmm. I thought you said it was n log n...
"Pick and zot" doesn't do any movement at all, but leaves all the
"zotted" entries in place to be skipped over on the next pass.
It's good for sorting less than ten things. ;-) And it is _very_
short.
-michael
Check out amazing quality 8-bit Apple sound on my
Home page: http://members.aol.com/MJMahon/