topN using a heap

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sat Jan 16 18:10:35 PST 2016


On 1/16/16 5:27 PM, Ivan Kazmenko wrote:
> On Saturday, 16 January 2016 at 15:25:50 UTC, Andrei Alexandrescu wrote:
>> 3. At the end, swap the largest in the heap with the 10th and you're
>> done!
>
> And why this?  Do we additionally require the k-th element to arrive
> exactly on k-th place?

Yes. -- Andrei



More information about the Digitalmars-d mailing list