### 2 releases

0.1.1 | Feb 24, 2023 |
---|---|

0.1.0 | Feb 24, 2023 |

#**34** in #modification

**MIT**license

6KB

93 lines

# permutations_iter

An iterative permutation generator *without recursion* for Rust.

Iterator

generates permutations of `Permutations ::`of

`(`n

`)`

`0``..`n

iteratively using
Steinhaus-Johnson-Trotter algorithm with Even's modification.Each

call has $O(n)$ time and space complexity.`next``(``)`

Not optimized. At all. Any improvements are welcome.

Published under MIT license.

###
`lib.rs`

:

Generate permutations iteratively without recursion.

function generates an iterator instance for permutations of `Permutations .of(n)`

`0``..`n

.

uses Steinhaus-Johnson-Trotter algorithm with Even's modification to generate the next permutation
in $O(n)$ time.`Permutations .next()`

Each iterator is one-way. You need to construct a new one for iterating again.