Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site u1100s.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!whuxlm!spuxll!abnji!u1100a!u1100s!sjs From: sjs@u1100s.UUCP (Stan Switzer) Newsgroups: net.math Subject: Re: YASMP (Yet Another Sorting Methods Posting) Message-ID: <208@u1100s.UUCP> Date: Fri, 28-Jun-85 14:26:50 EDT Article-I.D.: u1100s.208 Posted: Fri Jun 28 14:26:50 1985 Date-Received: Sun, 30-Jun-85 01:45:35 EDT References: <3070@cca.UUCP> <80@rtp47.UUCP> Reply-To: sjs@u1100s.UUCP (Stan Switzer) Organization: Bell Communications Research, Piscataway, NJ Lines: 42 Summary: In article <80@rtp47.UUCP> throopw@rtp47.UUCP (Wayne Throop) writes: > > 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. > > 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. > .... > [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 Sorry Wayne, but this one is getting old. 1) How many bins? Call it 'a' 2) How much duplication? d =/n ( n = #records ) Notice that: n log dn = log 2 n ( log d + log n ) a a 2 2 But since we have 'a' and 'd' (and 2 :-) constant, it is pretty clear that RADIX SORT is O(n log dn) == O(n log n) a Enough? Stan Switzer ihnp4!u1100s!sjs "Now where DID I leave my fish?"