But this algorithm is recursive, it's not good. I wrote a function Next_permutation that takes any permutation and calculates the next permutation by this algorithm!
This list of N! permutations has two great features:
1. All permutations can be arranged on a circle and each one differs from two neighbor by 1 transposition neighboring elements.
2. Calculation of first N!/2 permutations is enough, because list of the next N!/2 permutations is mirror-symmetric to the list of first N!/2 permutations! We simply reverse each of first N!/2 permutations to get other N!/2!
I've attached simple console test app. While the function is not optimized and not combed. I hope it can be used in combinatorial mathematic.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum