RECPERMS (Recursive Permutations)

Produce permutations of the integers from 1 to n recursively one at a time.
1K download
Aggiornato 27 nov 2006

Visualizza la licenza

RECPERMS(n,p), where n is a positive integer, and p is a valid permutation of the integers from 1 to n, returns a vector with n elements containing the next permutation of the integers from 1 to n.
If RECPERMS(n,p) is called n!-1 times recursively (i.e feeding the output vector into the function for the next step) starting with p = 1:n, then
the successive outputs span the same output from perms(1:n). The order of the permutations is, however, different from that of perms(1:n), which
uses a different algorithm.
If the input p is 1:n, the used algorithm results in the last permutation being n:-1:1. Starting with p=1:n is, however, optional. The function is
designed to wrap to the first permutation (1:n) when the last permutation (n:-1:1) is reached. This way, if any (valid) starting permutation p is
used, then recursively calling the function n!-1 times spans all possible permutations as expected.

Cita come

Khaled Hamed (2025). RECPERMS (Recursive Permutations) (https://it.mathworks.com/matlabcentral/fileexchange/13101-recperms-recursive-permutations), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2006b
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Categorie
Scopri di più su Design, Analysis, Benchmarking, and Verification in Help Center e MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Versione Pubblicato Note della release
1.0.0.0