Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site rtp47.UUCP Path: utzoo!watmath!clyde!burl!ulysses!unc!mcnc!rti-sel!rtp47!throopw From: throopw@rtp47.UUCP (Wayne Throop) Newsgroups: net.math Subject: YASMP (Yet Another Sorting Methods Posting) Message-ID: <80@rtp47.UUCP> Date: Thu, 27-Jun-85 18:29:45 EDT Article-I.D.: rtp47.80 Posted: Thu Jun 27 18:29:45 1985 Date-Received: Sat, 29-Jun-85 00:39:12 EDT References: <3070@cca.UUCP> Organization: Data General, RTP, NC Lines: 33 > Finally, radix sorting is O(n log n), at best. The > reason is that the keys must be at least log n bits long to > represent n distinct keys. > Richard Harter, SMDS Inc. > (Running at g-rh@cca-unix) Not quite. Radix sorting is O(n * m), where n is the number of records, and m is some muliplier derived from the length of the key. However, the multiplier m is NOT related to the number of records, but to the way the instance of the radix sort algorithm chooses to view the keys. While it is true that the keys must be at least log n bits long to get unique keys, this does not limit the speed of the radix sort, since a) more than one bit is processed "at a time", and b) the keys need not be unique. Again, *comparison sorting* is limited to O(n log n), because of the fundamental nature of sorting by comparing keys. Other forms of sorting are *not* limited to O(n log n), but they *cannot* depend (totally) on comparison. Radix sorting does not in any way depend on comparing keys, in the same sense that a person processing mail doesn't need to compare the zip codes on one of the letters to the zip codes on the others. [Also, read Knuth's "Sorting and Searching"... it contains all of the above, and a lot more. It explicitly states these properties of radix sort.] [As a trivial example to show that the m in the O(n * m) radix sort can be smaller than log n, with more than n possible keys, consider sorting keys which are integers from 0 to 3. There are (log2 4) bits in these keys, but clearly a radix sort in this case still takes only n operations, not 2n.] -- Wayne Throop at Data General, RTP, NC!mcnc!rti-sel!rtp47!throopw