A Simple Bubble Sort Function
Gary Perlman
gsp at ulysses.UUCP
Tue Jun 12 10:12:26 AEST 1984
> Jack Purdum is rapidly getting a reputation as an idiot with me. I thought
> that by now *EVERYBODY* knew that the bubble sort is for cretins. If you
> want a quick simple sort, write a "selection sort": search 0 thru n for the
> largest item and swap it with the item in slot n; repeat with n=n-1 until
> done. This is exactly the effect that the bubble sort achieves (think about
> it for a while if you aren't sure), but without all the unnecessary exchanges.
> Moral: Don't waste your effort optimizing the wrong solution to the problem.
> Geoff Kuenning
> Callan Data Systems
> ...!ihnp4!wlbr!callan!geoff
It is true that bubble sort is about as bad an algorithm as can be found.
Floor sort, used by me when I once dropped my FORTAN deck, is a bit worse.
Still, bubble sort is useful as a teaching tool, and its impracticality
makes it unlikely that teachers can find implementations of it in C.
I have trouble finding serious fault with anyone generous enough to
post their software to net.sources. I realized that I was free to ignore it.
So while I can't cheer for the posting of some code that people should not use
for efficiency's sake, I find personal attacks in very poor taste.
For another non-optimal sorting routine, see the standard C text,
The C Programming Language (Prentice Hall) for a shell sort routine.
For small arrays, it gives remarkably good results for such a small procedure.
Gary Perlman BTL MH 5D-105 (201) 582-3624 ulysses!gsp
More information about the Comp.sources.unix
mailing list