2 Open Problems on Partial Words 31
∆
n
=2
n−1
We end this section with the following open problem.
Open problem 15 Exhibit an algorithm to sample uniformly (weak) period
sets through irreducible (weak) period sets.
2.6 Primitive and Unbordered Partial Words
The two fundamental concepts of primitiveness and borderedness play an im-
portant role in several research areas including coding theory [5, 6, 117], com-
binatorics on words [45, 92, 93, 94, 96], computational biology [39, 100], data
communication [41], data compression [49, 119, 123], formal language theory
[57, 58], and text algorithms [38, 50, 51, 52, 69, 72, 84, 102, 118]. A primitive
word is one that cannot be written as a power of another word, while an un-
bordered word is a primitive word such that none of its proper prefixes is one
of its suffixes. For example, ab
aab is bordered with border ab while abaabb is
unbordered. The number of primitive and unbordered words of a fixed length
over an alphabet of a fixed size is well known, the number of primitive words
being related to the Möbius function [92].
In this section, we discuss, in particular, the problems of counting primitive
and unbordered partial words.
2.6.1 Primitiveness
Awordu is primitive if there exists no word v such that u = v
i
with i ≥ 2.A
natural algorithmic problem is how can we decide efficiently whether a given
word is primitive. The problem has a brute force quadratic solution: divide
the input word into two parts and check whether the right part is a power of
the left part. But how can we obtain a faster solution to the problem? Fast
algorithms for testing primitivity of words can be based on the combinatorial
result that a word u is primitive if and only if u is not an inside factor of its
square uu,thatis,uu = xuy implies x = ε or y = ε [45]. Indeed, any linear
time string matching algorithm can be used to test whether the string u is a
proper factor of uu. If the answer is no, then the primitiveness of u has been
verified [51]. So testing whether or not a word is primitive can be done in
linear time in the length of the word.
Primitive partial words were defined in [9]: A partial word u is primitive if
there exists no word v such that u ⊂ v
i
with i ≥ 2. It turns out that a partial
word u with one hole is primitive if and only if uu ↑ xuy for some partial words
x, y implies x = ε or y = ε [9]. A linear time algorithm for testing primitivity
of partial words with one hole can be based on this combinatorial result.
As an application, the existence of a binary equivalent for any partial word
with one hole satisfying Conditions 1–4 discussed in Section 2.5 was obtained
[16]. In [11], a linear time algorithm was described to test primitivity on