🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #1652

Re: Advice needed for fastest sort algorthm

#1652
From: John Tromp
Date: Fri, 20 Nov 1992 13:21
30 lines
1450 bytes
gjs@mustang.dsto.gov.au (Graeme Simpkin) writes:

>In fact almost everyone writes.....

>I am really interested in the answer to the original post here, but
>there appears to be a rolling discussion (and great I encourage it),
>but can I ask some kind soul to post an article at the end with the
>header:

Pretty fast (O(nlogn)) sort algorithm -> HERE IT IS
use at your won peril!

sort(t,j)               /* sort t[1] ... t[j] in ascending order */
int *t,j;
{
        int i,k,l,m;

        for (i = j/2; j > 1; t[l] = k) {
                if (i) k = t[i--]; else { k = t[j]; t[j--] = t[1]; }
                for (l = i + 1; (m = l + l) <= j; t[l] = t[m], l = m) {
                        if (m < j && t[m] < t[m+1]) m++;
                        if (t[m] <= k) break;
                }
        }
}


-John Tromp (tromp@cwi.nl)         f() is total -- R.L. Goodstein
define s(n){;auto e,r;for(0;n;n/=b)r+=n%b*(b+1)^s(e++);return(r)}
define f(n){;for(b=2;n;b++)n=s(n)-1;return(b)} for(n=0;1;n++)f(n)
Technical Details
Message-ID: <7956@charon.cwi.nl>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!cwi.nl!tromp
References: <BxD5pt.DyI@news.cso.uiuc.edu> <1dj6jmINNder@tartarus.uwa.edu.au> <1992Nov12.195155.14124@kth.se> <1992Nov20.094100.165181@dstos3.dsto.gov.au>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!cwi.nl!tromp
From: tromp@cwi.nl (John Tromp)
Newsgroups: rec.games.programmer
Subject: Re: Advice needed for fastest sort algorthm
Message-ID: <7956@charon.cwi.nl>
Date: 20 Nov 92 13:21:24 GMT
References: <BxD5pt.DyI@news.cso.uiuc.edu> <1dj6jmINNder@tartarus.uwa.edu.au> <1992Nov12.195155.14124@kth.se> <1992Nov20.094100.165181@dstos3.dsto.gov.au>
Sender: news@cwi.nl
Lines: 30