Article View: news.software.nntp
Article #64543Re: Newsreader programming - sorting one million lines ?
From: Heiko Studt
Date: Wed, 26 Mar 2003 21:52
Date: Wed, 26 Mar 2003 21:52
61 lines
4185 bytes
4185 bytes
J.B. Moreno did nothing on 26.03.2003 21:16:15: > > With bubble-sort you need only go and look and (at the end!) > > twist I with H. > A bubble sort is unsuitable for anything beyond a few hundred items, > some sort of insertion sort would be vastly preferable (preferably with > a dynamic index to speed things up). It was a small example. We are talking about a very huge article base of more than 10.000.000 articles. Therefor a 'normal' selectionsort/insertion sort without need is a bad thing. Exspecially if the list is presorted. I thought a bit more about the sorting-problem today, but I don't think my thoughts would be useful. It's too easy to be not found by another one and deleted after a 1-year-try to sort a small list. ;-) Perhaps I should talk about it in an algorithmic-group first, but yet I don't know where and if I should do so at all. If you say 'NOOO' say so and for me it would be EOT. Here I go: My idea has something to do with 'relative' extrema. It should help to sort (presort) a list with the best algorithmic useable for this purpose. We have a list of n items, now we go through this list and count how many items are going pass, those are 'x'. Now, if the item we found is smaller than the item before we decrease a second counter. Now we look three items backwards if there was an "extrema" during these. If no, we are going further. If there was an extrema we look back in our 'history' where our last extrema were. If the level-difference is very high we are sorting with the algorithmic we can do best for 'presorted' lists. (AFAIK Bubblesort) We can even look if there were only, let us say, six items in between. Therefor we don't need any sorting here. Afterwards we sort this part and save the level and the points where we have this pre-sorted-lists. Now we are going further. At the end we try to set the list together with the saved levels, so that allmost all parts are sorted. After this we can use a *small* bubblesort of at the maximum 20 going through. All this would be best for "presorted" lists, even if this would be a 'parabell', of course we need to reverse some parts of the sorted items, but this doesn't matter. The going-through for finding the extrema should need around n counts. ->O(n) The sorting of the parts should be, if the curve would be like sinus, around O(n/z), where z is the count between the extrema of the sinus. It's influenced by the settings we gave. The last sorting, if we analyse the levels of the extremas quite right, we would need around one going throughs. At all it would be in the best kind of need of sorting a O(n)*3. On the worst side of view it should *not* be O(n*(n/2)), it should be better. MFG, am confused. -- Heiko Studt
Technical Details
Message-ID:
<b5tb09.1hk.1@Heiko.Studt.dialin.t-online.de>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!news-lei1.dfn.de!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mailReferences:
<4540d.o33203@archiver.winews.net> <b5ob7g$akq$1@puck.litech.org> <Xns93492FF0660DBnothing@209.98.50.131> <07447.q33209@archiver.winews.net> <b5s66v.1t4.1@Heiko.Studt.dialin.t-online.de> <260320031516157694%planb@newsreaders.com>Show Full Headers
Complete Article Headers
Message-ID: <b5tb09.1hk.1@Heiko.Studt.dialin.t-online.de> Subject: Re: Newsreader programming - sorting one million lines ? Date: Wed, 26 Mar 2003 22:52:56 +0100 From: Heiko Studt <UsenetBecky@goldpool.org> References: <4540d.o33203@archiver.winews.net> <b5ob7g$akq$1@puck.litech.org> <Xns93492FF0660DBnothing@209.98.50.131> <07447.q33209@archiver.winews.net> <b5s66v.1t4.1@Heiko.Studt.dialin.t-online.de> <260320031516157694%planb@newsreaders.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!news-lei1.dfn.de!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mail Newsgroups: news.software.nntp Organization: HSR Lines: 60 Reply-To: Heiko.Studt@gmx.de Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: news.t-online.com 1048718109 02 1442 pZOuEi-SgYHF2 030326 22:35:09 X-Complaints-To: abuse@t-online.com X-ID: Tm4PjgZH8e3mYScUH2lb8SoK0yUcrrObZq-OJ1G5bzsGmHUOkaT3gM X-Mailer: Becky! ver. 2.05.10 with BkNews Plug-In ver. 2.0 User-Agent: Hamster-Pg/1.8