[Numpy-discussion] k maximal elements

David Cournapeau cournape@gmail....
Mon Jun 6 08:29:32 CDT 2011


On Mon, Jun 6, 2011 at 3:15 PM, Alex Ter-Sarkissov <ater1980@gmail.com> wrote:
> I have a vector of positive integers length n. Is there a simple (i.e.
> without sorting/ranking) of 'pulling out' k larrgest (or smallest) values.

Maybe not so simple, but does not require sorting (and its associated
o(NlogN) cost): http://en.wikipedia.org/wiki/Selection_algorithm


More information about the NumPy-Discussion mailing list