Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site sjuvax.UUCP Path: utzoo!watmath!clyde!floyd!harpo!decvax!ittvax!dcdwest!sdcsvax!akgua!psuvax1!burdvax!sjuvax!bbanerje From: bbanerje@sjuvax.UUCP Newsgroups: net.flame Subject: Re: A Simple Bubble Sort Function Message-ID: <362@sjuvax.UUCP> Date: Mon, 11-Jun-84 15:22:24 EDT Article-I.D.: sjuvax.362 Posted: Mon Jun 11 15:22:24 1984 Date-Received: Thu, 21-Jun-84 06:55:32 EDT References: <965@ihuxq.UUCP> <165@callan.UUCP> Organization: Saint Josephs Univ. Phila., Pa. Lines: 25 >> 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. >> The selection sort doesn't makes things that much better. Its still n^2. If you are sorting less than 15 items, you could do it very quickly with an insertion sort (Still n^2, but fast for few items). For more items, use a shell sort (decreasing order bubble sort). This is practically as quick and easy as the regular bubble sort, but quite a bit faster. (The selection sort is also for cretins) -- Binayak Banerjee {allegra | astrovax | bpa | burdvax}!sjuvax!bbanerje P.S. Send Flames, I love mail.