Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site pucc-i Path: utzoo!watmath!clyde!floyd!vax135!houxz!houxm!ihnp4!inuxc!pur-ee!CS-Mordred!Pucc-H:Pucc-I:ags From: ags@pucc-i (Seaman) Newsgroups: net.lang Subject: Re: Re: A Simple Bubble Sort Function - (nf) Message-ID: <320@pucc-i> Date: Mon, 18-Jun-84 11:15:36 EDT Article-I.D.: pucc-i.320 Posted: Mon Jun 18 11:15:36 1984 Date-Received: Thu, 21-Jun-84 00:37:16 EDT References: <7471@umcp-cs.UUCP> <26400014@uiucdcs.UUCP> Organization: Purdue University Computing Center Lines: 48 > But I wonder if using parallel processing might improve bubble sort's rating. > A parallel version would run in O(n). Is O(log n) possible? What is > the fastest known/possible parallel sorting method? Bjorn Mossberg of Control Data Corporation presented a paper on "Sorting on the CYBER 205" at the Symposium on CYBER 205 Applications, held at the Institute for Computational Studies at Colorado State University, Fort Collins, Colorado, Aug. 12-13, 1982. His empirically-derived timing formulas for vectorized versions of the three sorting algorithms which have been under discussion here (Bubble, Insertion and Quicksort) are as follows: (all logs are base e) 1. Bubble sort t(N) = N^2/2 + N(151 log N + 96) cycles This is still an O(N^2) algorithm, but faster than the scalar version. 2. Insertion sort t(N) = N^2/4 + 100N cycles (pure vector version) This is considerably faster than Bubble for all N. For sorting small lists, the 205 can do somewhat better with a scalar insertion sort that takes advantage of the large number of working registers on the machine. This method will sort a list of M elements (M small) in approximately t(M) = 15M^2/4 + 3M cycles. The preferred scheme would therefore be to do the first 27 steps in scalar mode, and the rest in vector mode. 3. Median-of-three Quicksort t(N) = 2.5N(36 + log N) cycles Note that for all reasonable values of N, the linear term dominates. In other words, for all lists small enough to fit into the mass storage available at a typical computer installation, the algorithm sorts in essentially linear time! The only known sorting algorithm that can compete with Quicksort on the CYBER 205 is Batcher's sort, and only for particular values of N. -- Dave Seaman "My hovercraft is full of eels." ..!pur-ee!pucc-i:ags