|0.1.1||Feb 24, 2023|
|0.1.0||Feb 24, 2023|
#8 in #permutation
30 downloads per month
An iterative permutation generator without recursion for Rust.
Permutations::of(n) generates permutations of
0..n iteratively using
Steinhaus-Johnson-Trotter algorithm with Even's modification.
next() call has $O(n)$ time and space complexity.
Not optimized. At all. Any improvements are welcome.
Published under MIT license.
Generate permutations iteratively without recursion.
Permutations.of(n) function generates an iterator instance for permutations of
Permutations.next() uses Steinhaus-Johnson-Trotter algorithm with Even's modification to generate the next permutation
in $O(n)$ time.
Each iterator is one-way. You need to construct a new one for iterating again.