Newsgroups: biz.comp,biz.jobs.offered,bln.comp.unix,comp.emacs,comp.ibm,comp.jobs,comp.jobs.offered,comp.lang.awk,comp.lang.c,comp.lang.c++,comp.object,comp.org.acm,comp.org.ieee,comp.os.linux,comp.os.minix,comp.os.unix,comp.programming,comp.programm
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mel.connect.com.au!munnari.OZ.AU!spool.mu.edu!newspump.sol.net!www.nntp.primenet.com!nntp.primenet.com!netcom.com!longyear
From: longyear@netcom.com.--- (Al Longyear)
Subject: Re: + + If you can answer this, do I have a job for you !!!
Message-ID: <longyearE224G8.Kpt@netcom.com>
Sender: longyear@netcom18.netcom.com
Reply-To: longyear@netcom.com (Al Longyear)
Organization: personal account at NETCOM Communications
References: <01bbe2c5$83e861e0$238303c7@business.blogic.com> <32A8BDB3.41C6@scilearn.com>
Date: Sat, 7 Dec 1996 18:52:56 GMT
Lines: 20
Xref: euryale.cc.adfa.oz.au biz.jobs.offered:676177 comp.emacs:32213 comp.lang.awk:3516 comp.lang.c:177680 comp.lang.c++:204956 comp.object:51316 comp.org.acm:4188 comp.org.ieee:3936 comp.os.minix:27261 comp.programming:33584

Thanassi Protopapas <protopap@scilearn.com> writes:

>Say you want the N highest values.  Set up an N-element array.
>Fill it up with the first N elements of your large array. Sort it.
>Go through your 500,000 integers ONCE, as follows:
>For each element past the initial N, if it's greater than your 
>Nth (smallest) estored number go up your N-array until you find a
>greater number. Slide everything down and insert your new number,
>so you still have the so-far-greatest N numbers sorted.
>When you're through all the items, your N-array will have your answer.

The fastest algorithm does not involve __ANY__ sort, no matter of any
type, at all.

However, that algorithm is for the student to find on his own. If he
suggest using a sort then it is wrong.


-- 
Al Longyear           longyear@netcom.com
