Combinatorial numbering rank and unrank

Translate between standard numbering and combinatorial numbering of n choose k.
103 téléchargements
Mise à jour 13 nov. 2015

Afficher la licence

The sequence of combinations defined by N-choose-k (no ordering, no replacement) form a sequence that can be lengthy. These routines provide a way to translate between this sequence and the standard sequence of whole numbers and to advance within the sequence. I find this quite useful when one desires to break this sequence into equal chunks for parallel processing purposes. These sets are assumed to be sorted into lexicographic (like alphabetic) order.
Short example with n=5, k=3:
set,s rank,r
------ -------
[1 2 3] 0
[1 2 4] 1
[1 2 5] 2
[1 3 4] 3
[1 3 5] 4
[1 4 5] 5
[2 3 4] 6
[2 3 5] 7
[2 4 5] 8
[3 4 5] 9
r = kSubsetLexRank(s,k,n)
s = kSubsetLexUnrank(r,k,n)
s = kSubsetLexSuccessor(curset,k,n)

Citation pour cette source

Brian Butler (2024). Combinatorial numbering rank and unrank (https://www.mathworks.com/matlabcentral/fileexchange/53976-combinatorial-numbering-rank-and-unrank), MATLAB Central File Exchange. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2015b
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur Sequence and Numeric Feature Data Workflows dans Help Center et MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Publié le Notes de version
1.0.0.0

* added fig.
* typo
* better fig.

* typo fixed. added 'requirement'