Index
Problem list
String
Necklace
References
TODO list
P41
: Enumeration of all $k$-ary necklaces
P41
:
Enumeration of all $k$-ary necklaces
Input:
$n$: a length of a necklace, $k$: a number of alphabet size.
Output:
All $k$-ary necklaces with length $n$.
Complexity:
$O(1)$ amortized per output and $O(n)$ space.
Comment:
A $k$-ary necklace is an equivalence class of k-ary strings under rotation.
Reference:
[
Ruskey1992
] (
Bibtex
)