Popular recipes tagged "quickselect"http://code.activestate.com/recipes/tags/quickselect/popular/2010-11-30T07:32:42-08:00ActiveState Code RecipesSelect some nth smallest elements, quickselect, inplace (Python)
2010-11-30T07:32:42-08:00Teodor Kichatovhttp://code.activestate.com/recipes/users/4176095/http://code.activestate.com/recipes/577477-select-some-nth-smallest-elements-quickselect-inpl/
<p style="color: grey">
Python
recipe 577477
by <a href="/recipes/users/4176095/">Teodor Kichatov</a>
(<a href="/recipes/tags/quickselect/">quickselect</a>, <a href="/recipes/tags/search/">search</a>, <a href="/recipes/tags/selection/">selection</a>).
</p>
<p>fork of <a href="http://code.activestate.com/recipes/269554-select-the-nth-smallest-element/" rel="nofollow">http://code.activestate.com/recipes/269554-select-the-nth-smallest-element/</a>
O(n) quicksort style algorithm for looking up data based on rank order. Useful for finding medians, percentiles, quartiles, and deciles. Equivalent to [data[n] for n in positions] when the data is already sorted.</p>