Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site dartvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!unc!mcnc!decvax!dartvax!chuck From: chuck@dartvax.UUCP (Chuck Simmons) Newsgroups: net.math Subject: Re: YASMP (Yet Another Sorting Methods Posting) Message-ID: <3316@dartvax.UUCP> Date: Mon, 1-Jul-85 18:26:15 EDT Article-I.D.: dartvax.3316 Posted: Mon Jul 1 18:26:15 1985 Date-Received: Thu, 4-Jul-85 00:22:09 EDT References: <3070@cca.UUCP> <80@rtp47.UUCP> <208@u1100s.UUCP> Organization: Dartmouth College, Hanover, NH Lines: 37 > > > 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) ... the keys need not be unique. > > 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?" Oops! 'd' is not constant. 'd' is more or less inversely proportional to 'n'. Typically, when we use a radix sort, 'n' will be large compared to the numnber of unique keys, 'd' will be small, and 'log d' will be negative. For the cases when we will be interested in using a radix sort, we will have the number of be about a**k for some positive integer 'k'. In this case: n loga (dn) = n loga ((a**k/n*)n) = n loga (a**k) = nk Now if we hold k constant and allow n to grow toward infinity, we have a sorting algorithm which is O(n). All this is pretty much as Wayne implied. -- Chuck