Generating Necklaces and Strings with Forbidden Substrings
نویسندگان
چکیده
Given a length m string f over a k-ary alphabet and a positive integer n, we develop eecient algorithms to generate (a) all k-ary strings of length n that have no substring equal to f, (b) all k-ary circular strings of length n that have no substring equal to f, and (c) all k-ary necklaces of length n that have no substring equal to f, where f is an aperiodic necklace. Each of the algorithms runs in amortized time O(1) per string generated, independent of k, m, and n.
منابع مشابه
Forbidden substrings on weighted alphabets
In an influential 1981 paper, Guibas and Odlyzko constructed a generating function for the number of length n strings over a finite alphabet that avoid all members of a given set of forbidden substrings. Here we extend this result to the case in which the strings are weighted. This investigation was inspired by the problem of counting compositions of an integer n that avoid all compositions of ...
متن کاملFast Algorithms to Generate Necklaces, Unlabeled Necklaces, and Irreducible Polynomials over GF(2)
Many applications call for exhaustive lists of strings subject to various constraints, such as inequivalence under group actions. A k-ary necklace is an Ž . equivalence class of k-ary strings under rotation the cyclic group . A k-ary unlabeled necklace is an equivalence class of k-ary strings under rotation and permutation of alphabet symbols. We present new, fast, simple, recursive algoŽ . rit...
متن کاملForbidden Substrings, Kolmogorov Complexity and Almost Periodic Sequences
Assume that for some α < 1 and for all nutural n a set Fn of at most 2 “forbidden” binary strings of length n is fixed. Then there exists an infinite binary sequence ω that does not have (long) forbidden substrings. We prove this combinatorial statement by translating it into a statement about Kolmogorov complexity and compare this proof with a combinatorial one based on Laslo Lovasz local lemm...
متن کاملA Gray Code for Necklaces of Fixed Density
A necklace is an equivalence class of binary strings under rotation In this paper we present a Gray code listing of all n bit necklaces with d ones so that i each necklace is listed exactly once by a representative from its equivalence class and ii successive representatives including the last and the rst in the list di er only by the transposition of two bits The total time required is O nN n ...
متن کاملGray codes for necklaces and Lyndon words of arbitrary base
Recently, a Gray code for unrestricted binary necklaces and their relatives was discovered by Vajnovszki [Discrete Mathematics & Theoretical Computer Science, to appear]. The Gray code is constructed by modifying the classical FKM algorithm for generating necklaces in lexicographic order. We present a generalisation of Vajnovszki’s algorithm, giving a Gray code for necklaces and their relatives...
متن کامل