develooper Front page | perl.perl5.porters | Postings from July 2004

Re: optimizing Short circuiting sort method based on [M]

Glenn Linderman
July 5, 2004 18:38
Re: optimizing Short circuiting sort method based on [M]
Message ID:
On approximately 7/5/2004 5:33 PM, came the following characters from
the keyboard of david nicol:

> I am wondering if I was somehow unclear in my proposed algorithm,
> archived at 
> which describes both bubble and inserting to place new elements in the
> short list.  

The algorithm seemed clear enough to me, but I couldn't figure out why 
you were interested in dealing with the short list.... if the bubble or 
heap sort on the long list returns data in sorted order, which it 
should, then

   push @short_list, &next_elem_from_incremental_sort();

should be adequate and optimal for putting data into the short list. 
This is sufficiently trivial that additional or alternative algorithms 
are not particularly interesting to me.

The interesting part of the job is figuring out how to pull the sorted 
data out of the long list without doing a complete sort, and without 
paying inordinate overhead needed by some fast sort algorithms, which 
are definitely worthwhile when sorting the whole list, but are not 
nearly as worthwhile when only needing a few elements.

Glenn --
The best part about procrastination is that you are never bored,
because you have all kinds of things that you should be doing. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About