image thumbnail

Min/Max selection

version 1.15.0.0 (20.5 KB) by Bruno Luong
Search for k smallest or largest elements in the array

7.9K Downloads

Updated 20 May 2016

View License

Using a partial quick-sort algorithm implemented with C-MEX. The complexity is O(n + k.log(k)), where n is the size of the array, and k is the number of elements to be selected.
Faster than SORT or multiple call of MIN/MAX for large size inputs.
Multidimensional capability supported

Cite As

Bruno Luong (2021). Min/Max selection (https://www.mathworks.com/matlabcentral/fileexchange/23576-min-max-selection), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2006b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!