Algorithm for nPk permutations ?

Started by
2 comments, last by Fruny 17 years, 11 months ago
Hello. I really need some algorithm for finding all nPk permutations (ordered sub-sets with lenght = k) Number of such permutations is n!/(n-k)! Thanks in advance.
Advertisement
If programming in C++, you can use the std::next_permutation and std::prev_permutation functions. The source code is available (in the <algorithm> header) in case you want to see the implementation (and thus the algorithm).
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Quote:Original post by Fruny
If programming in C++, you can use the std::next_permutation and std::prev_permutation functions. The source code is available (in the <algorithm> header) in case you want to see the implementation (and thus the algorithm).



Is there something in .NET platform for nPk ?
Quote:Original post by xxx_shinobi
Is there something in .NET platform for nPk ?


I don't know. I doubt it. Check the documentation.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement