Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ulysses.UUCP Path: utzoo!watmath!clyde!burl!ulysses!gsp From: gsp@ulysses.UUCP (Gary Perlman) Newsgroups: net.sources,net.followup,net.flame Subject: Re: A Simple Bubble Sort Function Message-ID: <879@ulysses.UUCP> Date: Mon, 11-Jun-84 20:12:26 EDT Article-I.D.: ulysses.879 Posted: Mon Jun 11 20:12:26 1984 Date-Received: Tue, 12-Jun-84 01:28:52 EDT References: <165@callan.UUCP> Organization: AT&T Bell Laboratories, Murray Hill Lines: 28 > 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