A fast NCHOOSEK alternative for engineers who like fast NCHOOSEK alternatives

Version 1.1.0.0 (2.6 KB) by Jose
This code recursively generates K-subsets of an N-set.
416 Downloads
Updated 27 Jan 2014

View License

GETNEXTCOMBINATION returns the next K-subset of an N-set. It implements the "Revolving Door" (NEXKSB) algorithm found in "Combinatorial Algorithms", 2nd Ed., by Albert Nijenhuis and Herbert S. Wilf. It is a recursive alternative to the NCHOOSEK command that is extremely fast (O(1)), at the expense of slightly more user interaction. (You do get something that NCHOOSEK does not give you for
this extra effort: see input "m".) Apart from its efficiency, it is awesome because each new K-subset differs from the last by a single element and the last combination generated differs from the first combination by a single element.

Cite As

Jose (2024). A fast NCHOOSEK alternative for engineers who like fast NCHOOSEK alternatives (https://www.mathworks.com/matlabcentral/fileexchange/45165-a-fast-nchoosek-alternative-for-engineers-who-like-fast-nchoosek-alternatives), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.1.0.0

typos

1.0.0.0