Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site godot.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!houxz!vax135!floyd!whuxle!mit-eddie!godot!bradley
From: bradley@godot.UUCP (Bradley C. Kuszmaul)
Newsgroups: net.sources,net.followup,net.flame
Subject: Re: A Simple Bubble Sort Function, glass houses
Message-ID: <131@godot.UUCP>
Date: Mon, 11-Jun-84 06:12:28 EDT
Article-I.D.: godot.131
Posted: Mon Jun 11 06:12:28 1984
Date-Received: Tue, 12-Jun-84 00:35:44 EDT
References: <965@ihuxq.UUCP> <165@callan.UUCP>
Organization: Thinking Machines, Waltham, MA
Lines: 27

Not nice to call someone an idiot, especially when you show your own ... er
... failure to keep up with the field.

The selection sort that you described is really no better than the bubble
sort under most conditions:
  bubble sort:  best time:  n steps
                worst time: n^2 steps
  selection sort: best time = worst time = 0.5*(n^2) steps
The selection sort is only better by a factor of two under the conditions
most favorable to it, and is sometimes worse by a factor of 0.5*n.  The
conditions under which bubble sort will win are when a file is "partly
sorted" already (i.e. the farthest a given element will have to travel
is small)

For good sorting algorithms, try quicksort (n^2 at worst n*log n at best,
with the "best" conditions much less restrictive than for bubble sort),
or something else.  (Quicksort and other sorting algorithms are discussed
in "Software Tools" by Kernighan and Plaugher (Excuse the spelling and possibly
incorrect name of the book) and "The Art of Computer Programming, vol II 
Sorting and Searching" by Knuth.

 --Bradley C. Kuszmaul
  {decvax!cca,ihnp4!mit-eddie,allegra!ias}!godot!bradley,
  "godot!bradley@mit-eddie"@MIT-XX.ARPA
-- 
  {decvax!cca,ihnp4!mit-eddie,allegra!ias}!godot!bradley,
  "godot!bradley@mit-eddie"@MIT-XX.ARPA