New Bounds and Extended Relations Between Prefix Arrays, Border Arrays, Undirected Graphs, and Indeterminate Strings

Similar documents
Generating p-extremal graphs

Abelian Pattern Avoidance in Partial Words

A Graph Polynomial Approach to Primitivity

How Many Holes Can an Unbordered Partial Word Contain?

Graph coloring, perfect graphs

Theory of Computation

The Chromatic Number of Ordered Graphs With Constrained Conflict Graphs

Induction and recursion. Chapter 5

Dynamic Programming. Shuang Zhao. Microsoft Research Asia September 5, Dynamic Programming. Shuang Zhao. Outline. Introduction.

arxiv: v1 [math.co] 25 Apr 2018

The Algorithmic Aspects of the Regularity Lemma

1 Basic Combinatorics

Classical Complexity and Fixed-Parameter Tractability of Simultaneous Consecutive Ones Submatrix & Editing Problems

CS1800: Mathematical Induction. Professor Kevin Gold

Algebraic Methods in Combinatorics

5 Set Operations, Functions, and Counting

Laplacian Integral Graphs with Maximum Degree 3

On improving matchings in trees, via bounded-length augmentations 1

Reverse mathematics of some topics from algorithmic graph theory

Automorphism groups of wreath product digraphs

On the hardness of losing width

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005

Chapter Summary. Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms

The Strong Largeur d Arborescence

arxiv: v1 [math.co] 28 Oct 2016

Generalized Pigeonhole Properties of Graphs and Oriented Graphs

Combinatorial Optimization

1 Some loose ends from last time

On Aperiodic Subtraction Games with Bounded Nim Sequence

Induced subgraphs of prescribed size

Countable Menger s theorem with finitary matroid constraints on the ingoing edges

A Characterization of (3+1)-Free Posets

Tree-width and planar minors

Strongly chordal and chordal bipartite graphs are sandwich monotone

Index coding with side information

Induction and Recursion

On the number of cycles in a graph with restricted cycle lengths

The concentration of the chromatic number of random graphs

A Universal Turing Machine

MATH 324 Summer 2011 Elementary Number Theory. Notes on Mathematical Induction. Recall the following axiom for the set of integers.

Information Theory and Statistics Lecture 2: Source coding

On the hardness of losing width

LECTURE 6 Separating Hyperplanes (preliminary version)

Preliminaries and Complexity Theory

CS6901: review of Theory of Computation and Algorithms

Linear-Time Algorithms for Finding Tucker Submatrices and Lekkerkerker-Boland Subgraphs

Equational Logic. Chapter Syntax Terms and Term Algebras

2 Generating Functions

The chromatic number of ordered graphs with constrained conflict graphs

A fast algorithm to generate necklaces with xed content

Bi-Arc Digraphs and Conservative Polymorphisms

Notes 6 : First and second moment methods

THE GRIGORCHUK GROUP

Definition 2.3. We define addition and multiplication of matrices as follows.

Semidefinite and Second Order Cone Programming Seminar Fall 2001 Lecture 5

Discrete Applied Mathematics

Lecture notes on the ellipsoid algorithm

arxiv: v1 [math.co] 20 Oct 2018

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

Trees. A tree is a graph which is. (a) Connected and. (b) has no cycles (acyclic).

Cographs; chordal graphs and tree decompositions

Math 324 Summer 2012 Elementary Number Theory Notes on Mathematical Induction

Automata Theory and Formal Grammars: Lecture 1

Chapter 3: Propositional Calculus: Deductive Systems. September 19, 2008

Nowhere 0 mod p dominating sets in multigraphs

Nordhaus-Gaddum Theorems for k-decompositions

Efficient Reassembling of Graphs, Part 1: The Linear Case

Applications of the Lopsided Lovász Local Lemma Regarding Hypergraphs

k-protected VERTICES IN BINARY SEARCH TREES

Tree sets. Reinhard Diestel

A Questionable Distance-Regular Graph

Climbing an Infinite Ladder

On shredders and vertex connectivity augmentation

k-blocks: a connectivity invariant for graphs

CS60007 Algorithm Design and Analysis 2018 Assignment 1

Algebraic Methods in Combinatorics

Stat 451: Solutions to Assignment #1

With Question/Answer Animations

CSCE 551 Final Exam, April 28, 2016 Answer Key

Notes on Freiman s Theorem

COUNTING NUMERICAL SEMIGROUPS BY GENUS AND SOME CASES OF A QUESTION OF WILF

arxiv: v1 [math.co] 22 Jan 2013

DISTINGUISHING PARTITIONS AND ASYMMETRIC UNIFORM HYPERGRAPHS

Harvard CS121 and CSCI E-121 Lecture 2: Mathematical Preliminaries

Models of Computation. by Costas Busch, LSU

Bulletin of the Iranian Mathematical Society

Reconstructibility of trees from subtree size frequencies

Sorting suffixes of two-pattern strings

7. Lecture notes on the ellipsoid algorithm

In N we can do addition, but in order to do subtraction we need to extend N to the integers

Acyclic subgraphs with high chromatic number

Fine and Wilf s Periodicity on Partial Words and Consequences

Multi-coloring and Mycielski s construction

Near-domination in graphs

Isomorphisms between pattern classes

Dynamic Programming on Trees. Example: Independent Set on T = (V, E) rooted at r V.

Partial cubes: structures, characterizations, and constructions

Computational Theory

Axioms for Set Theory

Transcription:

New Bounds and Extended Relations Between Prefix Arrays, Border Arrays, Undirected Graphs, and Indeterminate Strings F. Blanchet-Sadri Michelle Bodnar Benjamin De Winkle 3 November 6, 4 Abstract We extend earlier works on the relation of prefix arrays of indeterminate strings to undirected graphs and border arrays. If integer array y is the prefix array for indeterminate string w, then we say w satisfies y. We use a graph theoretic approach to construct a string on a minimum alphabet size which satisfies a given prefix array. We relate the problem of finding a minimum alphabet size to finding edge clique covers of a particular graph, allowing us to bound the minimum alphabet size by n + n for indeterminate strings, where n is the size of the prefix array. When we restrict ourselves to prefix arrays for partial words, we bound the minimum alphabet size by n. Moreover, we show that this bound is tight up to a constant multiple by using Sidon sets. We also study the relationship between prefix arrays and border arrays. We give necessary and sufficient conditions for a border array and prefix array to be satisfied by the same indeterminate string. We show that the slowly-increasing property completely characterizes border arrays for indeterminate strings, whence there are exactly C n distinct border arrays of size n for indeterminate strings (here C n is the nth Catalan number). We give an algorithm to enumerate all prefix arrays for partial words of a given size, n. Our algorithm has a time This material is based upon work supported by the National Science Foundation under Grant No. DMS 6775. Part of this paper will be presented at STACS 4 [4]. Department of Computer Science, University of North Carolina, P.O. Box 67, Greensboro, NC 74 67, USA, blanchet@uncg.edu Department of Mathematics, University of California, San Diego, 95 Gilman Drive #, La Jolla, CA 993, USA 3 Department of Mathematics, Tufts University, 53 Boston Avenue, Medford, MA 55, USA

complexity of n 3 times the output size, that is, the number of valid prefix arrays for partial words of length n. We also bound the number of prefix arrays for partial words of a given size using Stirling numbers of the second kind. Keywords: Indeterminate strings; Partial words; Prefix arrays; Border arrays; Undirected graphs. Introduction Strings are sequences of letters from a given alphabet. They have been extensively studied and several generalizations have been proposed in the literature which include indeterminate strings and strings with don t cares [,, 3]. An indeterminate string allows positions to be subsets of cardinality greater than one of a given alphabet, while a string with don t cares allows positions to be the given alphabet. For example, a{a, b}bb{a, c} is an indeterminate string of length 5 on the alphabet {a, b, c} and a{a, b, c}bb{a, b, c} is a string with don t cares of same length on that alphabet. Strings with don t cares are also referred to as partial words and the don t care symbol is often represented by the symbol, or hole symbol, which represents the alphabet. An alternative way of writing our example a{a, b, c}bb{a, b, c} is a bb. Strings where each position is a singleton subset are referred to as regular strings. The fundamental concept of border array has played an important role in pattern matching for over four decades [7, 6]. If non-empty strings u, u, v, v exist such that w = u v = v u and u matches u, denoted by u u, then string w has a border of length u = u. The border array β corresponding to a string w of length n is an integer array of same length such that for j..n, β[j] is the length of the longest border of w[..j]. For example, a{a, b}bb{a, c} and a bb give rise to the border arrays 3 and 34, respectively. For a regular string w, any border of a border of w is also a border of w; thus w s border array gives all the borders of every prefix of w. This desirable property is lost however, when we consider indeterminate strings or partial words, due to the lack of the transitivity of (e.g., a {a, b} and {a, b} b, but a b implying that w = a{a, b}b has a border of length having a border of length, but w has no border of length ). Smyth and Wang [7] showed that for indeterminate strings, the concept of prefix array provides more information than the one of border array and specifies all the borders of every prefix. The prefix array y corresponding to a string w of length n is an integer array of same length such that for j..n,

y[j] is the length of the longest prefix of w[j..n) that matches a prefix of w. For example, a{a, b}bb{a, c} and a bb give rise to the prefix arrays 53 and 54, respectively. Main and Lorentz [4] described the first algorithm for computing the prefix array of any given regular string as a routine in their well-known algorithm for finding all repetitions in a regular string, and Smyth and Wang [7] described an algorithm for efficiently computing the prefix array of any given indeterminate string. The reverse problem of the one of designing an algorithm that computes the prefix array of any given string is the problem of designing an algorithm that tests if an integer array is the prefix array of some string and, if so, constructs such a string. Clément et al. [6] described an O(n) time algorithm that tests if an integer array of size n is the prefix array of some regular string and, if so, constructs the lexicographically least string having it as a prefix array, the alphabet size of the string being bounded by log n. Recently, Christodoulakis et al. [5] described an algorithm for computing an indeterminate string corresponding to a given feasible prefix array. Such algorithmic characterizations of prefix arrays are not only interesting from a theoretical point of view, but also from a practical point of view, e.g., they help in the design of methods for randomly generating prefix arrays for software testing. Christodoulakis et al. [5] established quite unexpected connections between indeterminate strings, prefix arrays, and undirected graphs. Among them, they proved the surprising result that every feasible array is the prefix array of some string. In this paper, we extend connections between indeterminate strings, prefix/border arrays, and undirected graphs, which yield combinatorial insights. The contents of our paper are as follows: In Section, we review some basics. In Section 3, we revisit the problem of constructing an indeterminate string on a minimal alphabet satisfying a given feasible prefix array y. We describe two methods: the first one relies on a graph Q y built from y s associated prefix graph P y, while the second one examines induced subgraphs of P y. It turns out that the minimum alphabet size is the chromatic number of Q y and is also the size of the smallest induced positive edge cover of P y. We bound the minimum alphabet size for an array of size n by n+ n using results of Alon, Erdős et al., and Lovász on edge clique covers. In Section 4, we explore the relationship between prefix arrays and border arrays. In particular, we show that every slowly-increasing array is the border array for some indeterminate string, whence the number of border arrays of size n for indeterminate strings is the nth Catalan number. In Section 5, we restrict prefix arrays to partial words. We give a characterization of such 3

prefix arrays y in terms of the prefix graph P y. Moreover, we give a method to construct a partial word on the smallest possible alphabet for a given prefix array. We bound the minimum alphabet size for an array of size n n by, this bound being tight (up to a constant multiple) using results of Erdős and Túran on Sidon sets. We give an algorithm which enumerates all prefix arrays of size n which are valid for partial words. Our algorithm runs in time n 3 times the output size. We also bound the number of prefix arrays of a given size valid for partial words using Stirling numbers of the second kind. Finally in Section 6, we conclude with some suggestions for future work. Preliminaries Throughout the paper, we use many graph theoretical concepts and constructions. We refer the reader to [] for an introduction to these ideas. A string w on alphabet A is a sequence of non-empty subsets of A, or may be empty. If A has cardinality µ, we also say that w is a string on µ letters. We call a -element subset of A a regular letter and larger subsets indeterminate letters. A string of all regular letters is called a regular string (also referred to as a word), and a string which contains at least one indeterminate letter is called an indeterminate string. A hole, denoted by, is an indeterminate letter which consists of the full alphabet, A. A partial word is a string which consists of only regular letters and holes. We denote the length of string w by w. Two non-empty subsets of A, α and α, match if they have non-empty intersection. We denote this by α α. Similarly, two strings w and w match if w = w and w[i] w [i] for each i.. w. As before, this is denoted by w w. An integer array y of size n such that y[] = n and for every i..n, y[i] n i, is called feasible. The prefix array of a string w of length n is an array of integers y such that y[j] is the length of the longest prefix of w[j..n) that matches a prefix of w. Note that y[] is the size of y for any prefix array y. If y is the prefix array of some regular string, then y is called regular. If y is the prefix array of some partial word, then y is called valid for partial words. If y is the prefix array of a string w, then w satisfies y. Lemma. [5] An integer array y of size n is the prefix array of a string w of length n if and only if for each position i..n, the following two conditions hold: () w[..y[i]) w[i..i + y[i]) and () if i + y[i] < n, then w[y[i]] w[i + y[i]]. 4

7 6 3 4 5 Figure : Prefix graph P y for y = 843. Solid lines indicate positive edges and dashed lines indicate negative edges. The most important graph construction that we use is that of the prefix graph, which is introduced in [5]. The prefix graph of a prefix array, y, of size n is denoted by P y and is constructed as follows. Its vertex set, V (P y ), is [..n). Its edge set consists of two types of edges. Let i..n. For j..y[i], {j, i+j} is a positive edge, while for i+y[i] < n, {y[i], i+y[i]} is a negative edge (refer to Lemma ). Let E + (P y ) be the set of positive edges of P y and E (P y ) be the set of negative edges of P y (note we may write just E + or E, respectively, when P y is clear from context). We write P y + = (V (P y ), E + (P y )) (i.e., the graph with the same vertex set, but with only the positive edges) and Py = (V (P y ), E (P y )) (same vertex set, only the negative edges). A string w satisfies negative edge {i, j} if w[i] w[j] and w violates {i, j} if w[i] w[j]. Similarly, w satisfies positive edge {i, j} if w[i] w[j] and w violates {i, j} if w[i] w[j]. The graph P y encodes all the information of the prefix array y, that is to say, that string w satisfies y if and only if w satisfies all positive and negative edges of P y. Figure shows an example. Lemma. Let y be a feasible prefix array and w be an indeterminate string satisfying y. If in P y, j and j k are joined by a negative edge and j, j,..., j k is a path on only positive edges, then there exists some i..k such that w[j i ] is an indeterminate letter. Proof. Assume, by way of contradiction, that w[j i ] is a regular letter for each i..k. Note w[j i ] w[j i+ ] for each i..k, because {j i, j i+ } is a positive edge. Moreover, because w[j i ] and w[j i+ ] are regular letters, it must be that w[j i ] = w[j i+ ]. This implies w[j ] = w[j ] = = w[j k ]. 5

However, this is a contradiction, because {j, j k } is a negative edge, which implies w[j ] w[j k ]. 3 Constructing Indeterminate Strings for Prefix Arrays Returning to Figure, {a, c, e}{a, b}{a, b}{b, d}{c, d}ebb satisfies the prefix array y = 843. It is constructed on an alphabet of five letters a, b, c, d, e. Is the alphabet size minimal? The answer is no since {a, b}{a, c}{b, c}{c, d}{a, d}bcc also satisfies y but is constructed using only the four letters a, b, c, d. We describe two methods for constructing indeterminate strings on a minimum alphabet size that satisfy a given prefix array. For ease of notation, if y is a feasible prefix array, let µ(y) denote the minimum alphabet size for an indeterminate string that satisfies y. 3. Constructing strings with minimum alphabet size: First method Let us describe our first method. Let V + be the set of vertices of P y which are incident to a positive edge. We construct a new graph Q from P y as follows: V (Q) = E + {{i, i} i V \ V + }, and {{i, j }, {i, j }} E(Q) if and only if there exists some {r, s} E such that r {i, j } and s {i, j }. Since a prefix array y defines a unique P y, which in turn defines a unique Q, we can call this graph Q y. We show how proper colorings of Q y and indeterminate strings satisfying y are related. Figure gives an example. Since Q y has chromatic number, associate a with vertices {, } and {, 3}, and b with vertices {, 3}, {, 4}, and {5, 5}. By assigning letters to each vertex in P y corresponding to the letters associated with its incident positive edges, we obtain the indeterminate {a}{b}{a}{a, b}{b}{b} which satisfies 6. Theorem. Let µ be the minimum alphabet size for a string satisfying a given feasible prefix array y. Then χ(q y ) = µ, where χ(q y ) denotes the chromatic number of Q y. Proof. Let P = P y and Q = Q y. Suppose w is a string on µ letters which satisfies y, and associate a distinct color to each letter. For each edge {i, j} 6

5, 3, 5, 5 3 4, 3, 4 Figure : P y (left) and Q y (right) for the prefix array y = 6, where solid lines indicate positive edges and dashed lines indicate negative edges. E + {{i, i} i V \ V + }, color the vertex {i, j} in Q with the color associated to the first element in w[i] w[j]. The intersection is always nonempty because positive edges and loops represent matchings. Now suppose there is an edge connecting the vertices {i, j} and {r, s} in Q. Then there is a negative edge in P connecting one endpoint of {i, j} to an endpoint of {r, s}. Without loss of generality, assume {i, r} E. This implies w[i] w[r] =, so {i, j} and {r, s} must have different colors. Thus, we have obtained a proper coloring of Q with µ colors, so χ(q) µ. Now suppose we are given a proper coloring of Q using χ(q) colors. We may think of each color as a letter and construct an indeterminate string w by assigning to w[i] the color of each {k, j} V (Q) such that i = k or i = j. Let {i, j} be any positive edge of P. Then w[i] and w[j] both contain the color given to {i, j}, so it is satisfied. It remains to show that each negative edge is also satisfied. Suppose {i, j} E. Then w[i] = {c c is the color on some {i, r} E + }, and w[j] = {c c is the color on some {j, s} E + }. Moreover, if {i, r}, {j, s} E +, then they are connected by an edge in Q y, so they have a different color. Hence w[i] w[j] =, so {i, j} is satisfied. Therefore, w satisfies y. Moreover, w uses at most χ(q) letters, which implies µ χ(q). 3. Constructing strings with minimum alphabet size: Second method Let us describe our second method. Suppose indeterminate string w on alphabet A = {a, a,..., a µ } satisfies prefix array y, and define V i = {j a i w[j]}. Notice that the subgraph of P y induced by V i contains no negative edges. Moreover, each positive edge is in the subgraph induced by some V i. This observation motivates the 7

6 5 3 4 Figure 3: P y for y = 76, where solid lines indicate positive edges and dashed lines indicate negative edges. One IPEC for P y is given by the sets V = {,, 5}, V = {,, 3}, V = {,, 4}, and V 3 = {3, 4, 5, 6}. The construction in Theorem gives the indeterminate string w = {a, b}{a, c}{b, c}{b, d}{c, d}{a, d}d, which satisfies y. following definitions. A subgraph of P y is negative-free if it does not contain any negative edges. We use the notation P y [V i ] to denote the subgraph of P y induced by V i. A set {V, V,..., V k }, where V i V (P y ), is an induced positive edge cover (IPEC) of P y if P y [V i ] is negative-free for all i..k, each positive edge of P y is in some P y [V i ], and each vertex of P y is in some P y [V i ]. Figure 3 gives an example of an IPEC. Theorem. Let y be a feasible prefix array. The minimum alphabet size for an indeterminate string satisfying y is exactly the size of the smallest IPEC of P y. Proof. Let µ be the minimum alphabet size for an indeterminate string satisfying y, and let σ be the size of the smallest IPEC of P y. Suppose w is an indeterminate string that satisfies y on the alphabet {a, a,..., a µ }. Let V i be as defined above. We claim {V, V,..., V µ } is an IPEC of P y. It is clear that each vertex is in some V i, because each position of w is non-empty. Suppose {i, j} is a negative edge of P y. Since w satisfies y, it must satisfy {i, j}, so w[i] w[j] =. Hence there is no V k which contains both i and j, which implies {i, j} is not in P y [V k ] for any k. This holds for any negative edge, so each P y [V k ] is negative-free. Now suppose {i, j} is a positive edge of P y. As before, w must satisfy {i, j}, which implies there exists some a k w[i] w[j]. Then i, j V k, so {i, j} is in the subgraph induced by V k. This proves our claim and shows σ µ. Now suppose C = {V, V,..., V σ } is an IPEC of P y. Let {a, a,..., a σ } 8

be a collection of distinct letters and construct an indeterminate string w by setting w[i] = {a j i V j }. Since each i is in some V j, w[i] is non-empty for all i. We claim w satisfies y. Suppose i and j are connected by a negative edge in P y. Then there is no V k C which contains both i and j, so by construction, w[i] w[j] =. Hence all negative edges of P y are satisfied. Now suppose i and j are connected by a positive edge. This edge is in P y [V k ] for some V k C, which implies a k w[i] w[j], satisfying the positive edge. Thus all edges of P y are satisfied, which proves our claim. Note w uses σ letters, so µ σ. Therefore, µ = σ. We can use this construction to bound µ(y), but first we introduce a few concepts. Given a graph G, an edge clique cover of G is a set of cliques in G such that each edge of G is in at least one of these cliques. The edge clique cover number of G is the size of the smallest edge clique cover of G, which we denote by θ(g). We denote the complement of G by G, i.e., the graph defined by V (G) = V (G) and two vertices of G are joined by an edge if and only if they are not joined by an edge in G. Lemma 3. Let y be a feasible prefix array of( size ) n such that y n and y n(n )(n 3). Then µ(y) θ Py. ( ) Proof. Let θ = θ Py and let C = {V, V,..., V θ } be an edge clique cover of P y (that is, each V i V (P y )). Notice that each positive edge of P y is also an edge of P y, so each positive edge is in some P y [V k ]. Moreover, since each V k is a clique in P y, it must be that P y [V k ] is negative-free. Suppose that there exists some vertex, i, in P y such that i / V k for all V k C. This implies that i is connected to every other vertex by a negative edge. Notice that by our construction of P y, if {i, i} and {i, i + } are both edges in P y, they cannot both be negative. However, given our condition on i they must both be negative, unless either i = or i = n (in which case one of these edges does not exist). Thus, i = or i = n, but in these cases, y must be one of the excluded prefix arrays. So each vertex of P y is in some V k. Hence C is also an IPEC of P y, and by Theorem, µ(y) θ. Edge clique covers have been well studied, and we can use results on them to bound µ(y). Specifically, we use the following results. Theorem 3 ([9, Theorem ]). Let G be a graph on n vertices. Then θ(g) n 4. 9

Theorem 4 ([3, Theorem 5]). Let G be a graph on n vertices with m n 4 edges. Further, set k = ( n ) m (i.e., k is the number of edges in G) and let t be the greatest integer such that t t k. Then θ(g) k + t. Theorem 5 ([, Theorem.4]). Let G be a graph on n vertices with maximum degree d. Then θ(g) e (d + ) ln n, where e is the base of the natural logarithm. Now we can state a bound on µ(y). Theorem 6. Let y be a feasible prefix array of size n, and let r be the number of negative edges in P y. Then µ(y) min{r+ r+, e (d+) ln n}, where e is the base of the natural logarithm and d is the maximum degree of a vertex in P y. Proof. We use Lemma 3, so we first check the cases y = n and y = n(n )(n 3). Suppose y = n. Notice that y is satisfied by abb b. Similarly, if y = n(n )(n 3), then y is satisfied by aa ab. In both of these cases, any string satisfying y must have at least two letters. Moreover, in both of these cases r = n, hence µ(y) = min{r + r +, e (r + ) ln n} and the result holds. ( θ Py ( ) Py. Let θ = Thus, by Lemma 3, we may assume that µ(y) θ ). It follows from Theorem 5 that θ e (d + ) ln n. To get the r + r + bound, we apply Theorem 4, but this requires that Py has at least n 4 edges. Note that P y has ( n ) r edges. Since r < n, the number of edges in Py is at least ( ) n (n ) = n 3n+. Define the function f(n) = n 3n+ n 4 = n 6n+4 4. Whenever f is positive, Py has at least n 4 edges. Note that f(6) = >, and f (n) = n 3 is positive for any n > 3. Hence f is positive for all n 6. Note that the complement of Py is Py, which has r edges. Hence, by Theorem 4, if n 6 and t is the greatest integer such that t t r, then θ r + t. Notice that t < r +, so θ < r + r +. This just leaves the cases where n < 6. Note that in these cases, r + r + < e (d + ) ln n, because r < n. Moreover, we can easily check that for each combination of n and r, either Py has at least n n 4 edges, or 4 < r + r +. In the former case, we can apply Theorem 4 to give θ < r + r +. In the latter case, Theorem 3 gives us θ n 4, implying θ < r + r +. Since r n, we get the following corollary.

Corollary. Let y be a feasible prefix array of size n. Then µ(y) n+ n. The following proposition exhibits a prefix array whose negative graph contains a complete graph K n and which requires at least n letters to be satisfied, showing that there exist prefix arrays which require an arbitrarily large alphabet. Proposition. For all n, there exists a prefix array y of size n such that P y contains a K n. Proof. We provide a construction of such an array. For each n > construct the prefix array y n recursively as follows: let y = and y n = n y n (n )y n, where y k = y k[.. k ) for all k. Clearly, y n has size n. Assume that y n creates a K n in Py n on the vertices labeled,,, 3,..., n and consider the prefix array y n+ = n y n( n )y n. The induced subgraph of Py n+ on its first n vertices is identical to Py n, which we assumed contains a K n at vertices whose labels are k for k < n. We show that every such vertex is connected to n by a negative edge, which creates a K n+. Recall that every negative edge is of the form {y[i], i + y[i]}. Since every vertex k in Py n is connected to n by a negative edge, i.e., an edge of the form { k, n }, we have y n [ n k ] = k for k n. Since every entry of y n [.. n ) occurs in y n+ at its original position plus n we have y n+ [ n + n k ] = y n+ [ n k ] = k for k < n, so there is a negative edge from k to n k + k = n. These connect all vertices of the K n created by y n to the last vertex in Py n+, creating the desired K n+. By induction on n, we conclude that y n is a prefix array of size n whose negative prefix graph contains a K n. 4 Connecting Prefix Arrays and Border Arrays An indeterminate string, w, of length n has a border of length l..n if w[..l) w[n l..n). The border array, β[..n), of an indeterminate string w is an integer array such that β[] = and for i >, β[i] is the length of the longest border of w[..i]. For example, a{a, b}{a, b}bac has border array β = 33. A border array β is feasible if there exists an indeterminate string such that β is its border array. A prefix array y satisfies a border array β if all strings with prefix array y also have border array β. Theorem 7. Let β be a border array of size n. Then a prefix array y satisfies β if and only if the following two conditions hold: () β[j] y[j β[j] + ] for all j..n, and () y[i] j i for all i j β[j].

Proof. Let y be a prefix array that satisfies β and w be any string with prefix array y. Since w[..j] has a maximal border of length β[j], we have w[..β[j]) w[j β[j] +..j]. Since y[j β[j] + ] gives the length of the longest prefix of w that matches a prefix of w[j β[j] +.. w ), we have y[j β[j]+] β[j] which gives (). Now let i j β[j] and y[i] = j i+r for some r. Then w[..j i+r) w[i..j+r). If r > then w[..j i] w[i..j], so w[..j] has a border of length at least j i+. However, since β[j] j i, w[..j] has a maximal border of length j i, so r. Therefore y[i] j i, so () must hold. For the reverse implication, let y be a prefix array satisfying () and (), and w be a string with prefix array y. We show that w must have border array β. Let j..n be arbitrary. By () the factor of w of length β[j] starting at position j β[j] + matches w[..β[j]), so w[..j] has a border of length β[j]. To see that this border is maximal, suppose there exists a border of w[..j] with length β[j] + r for some r. Then y[j β[j] r + ] β[j] + r which contradicts (). Thus, y satisfies β. This characterization of prefix arrays which satisfy a given border array leads to a natural question: Given a border array, what degree of freedom do we have in creating a prefix array which satisfies it? The following corollary answers this question, but requires one property of border arrays referred to as the slowly-increasing property. Proposition. For any border array β = β[..n) feasible by some indeterminate string w, β[j + ] β[j] + for all j..n. Proof. Suppose β[j + ] = i for some integer i. This means that w[..i) w[j + (i )..j + ]. So, w[..i ) w[j + (i )..j], which implies that β[j] i. Thus, β[j + ] = i β[j] +. Corollary. Let y be a prefix array that satisfies border array β. Then β completely determines y[i], where i > if and only if β[i] = or there exists some j such that i = j β[j] +. Moreover, if i = j β[j] + for some j, then y[i] = β[j] for the largest j with this property. Proof. First note that by Theorem 7(), y[i] is completely determined by β to be if and only if β[i] =. Now suppose y[i] is completely determined by β and y[i] >. Since β forces a lower bound on y[i], there must exist some j such that i = j β[j] +. Finally, assume i = j β[j] + for some j. Moreover, assume that j is the largest integer with this property. By Theorem 7(), β[j] y[i]. If j = n, then i = n β[j], so n i = β[j] y[i]. Since n i is the greatest feasible value for y[i], it follows that y[i] = β[j].

Hence we may assume j < n. By the slowly-increasing property, β[j+] β[j] + ; however, if β[j + ] = β[j] +, then i = (j + ) β[j + ] +, which contradicts the maximality of j. Thus β[j + ] β[j]. This implies i = j β[j]+ (j+) β[j+]. Hence by Theorem 7(), y[i] (j+) i = (j + ) (j β[j] + ) = β[j]. Thus y[i] = β[j]. The slowly-increasing property characterizes border arrays of indeterminate strings. Theorem 8. Every slowly-increasing array is the border array for some indeterminate string. Proof. Since every feasible prefix array is satisfied by some indeterminate string, it suffices to show that the set of prefix arrays which satisfy any slowly-increasing array is non-empty and feasible. We use the conditions given in Theorem 7. Recall that if a prefix array y is feasible, y[i] n i for all i..n. Let β be a slowly-increasing array. For j..n we have that β[j] n (j β[j] + ), so satisfying () never forces y to be infeasible. Now we check that () and () never force an empty set of possible assignments to a position of a prefix array. Suppose to the contrary that there exist such positions j and j. Condition () gives β[j ] y[j β[j ] + ] and Condition () gives y[j β[j ] + ] j j + β[j ] for j β[j ] + j β[j ]. Since we assume no y can satisfy both of these, j (j β[j ] + ) < β[j ], or equivalently j j. This means that for i = j β[j ] +, there is no possible assignment for y[i] and thus no prefix array satisfying β. Condition () requires that i j β[j ], so in this case we have j β[j ] + j β[j ]. However, rearranging this gives β[j ] + j j + β[j ]. Since j j, this violates the slowly-increasing property of β, a contradiction. Thus, no such j and j can exist and we conclude that there exists a non-empty set of assignments to y[i] for each i, so β is feasible. The following theorem counts the total number of slowly-increasing arrays of a given size. Theorem 9. For all n, the number of slowly-increasing arrays of size n is C n = n+( n n ), the nth Catalan number. Proof. All feasible border arrays β = β[..n) have the slowly-increasing property. The number of binary trees with n nodes is known to be C n, so we exhibit a bijection between these trees and slowly-increasing arrays. 3

Figure 4: Binary tree corresponding to border array. Refer to Figure 4 to see an example of the construction outlined below. Define the right-depth of a node in a binary tree to be the number of right children that must be traversed from the root to reach that node. Slowly-increasing arrays to trees: Consider a slowly-increasing array β = β[..n). We choose for β[] to correspond to the root of the tree. Then, for each j..n, if β[j + ] β[j], begin from the deepest node of rightdepth β[j + ] on the path from the root to the node for β[j] and add a left child corresponding to β[..j + ]. If β[j + ] = β[j] +, add a right child to the node corresponding to β[j], and make the new node correspond to β[..j +]. All that remains to be shown is that a node with the appropriate right-depth exists, and that the child that we need to add is not already present in the tree. The appropriate right-depth exists on the path because in this construction, each node is inserted at right depth β[j + ]. Also, if a node acquires a right child, then it does so before it acquires a left child, so the child that needs to be added is not already present when it is time to add the child. Hence, we construct a tree from β. Trees to slowly-increasing arrays: Given a binary tree T with n nodes, we construct a slowly-increasing array. Start with an empty array β. We perform a depth-first traversal of T where we go right before going left. Whenever we encounter a node for the first time, we append its right-depth to the end of β. Clearly, the right-depth cannot increase by more than one at a time when doing this traversal, so β is slowly-increasing. This gives us the following corollary. Corollary 3. The number of distinct border arrays of size n for indeterminate strings is exactly the n th Catalan number, C n = n+( n n ). 4

5 5 4 3 P y 3 P y + [V ] Figure 5: P y (left) and P + y [V ] (right) for the prefix array y = 63 satisfied by the partial word ab b a, where solid lines indicate positive edges and dashed lines indicate negative edges. 5 Restricting Prefix Arrays to Partial Words Since a hole matches any other letter, the following lemma follows directly from Lemma. Lemma 4. Let y be the prefix array for some partial word w. Then w[i] can be a hole if and only if there does not exist j..n such that either () y[j] = i and i + j < n or () j + y[j] = i if and only if i is not incident to any negative edges in P y. The next theorem gives a characterization of prefix arrays which can be satisfied by a partial word. It is similar to a characterization of regular prefix arrays given by [5, Lemma ]. The proof idea is that w[i] is a regular letter for all i V, which implies that the entire connected component of i in P + y [V ] must be the same letter. Figure 5 gives an example of a prefix array valid for partial words. Theorem. Let y be a feasible prefix array and let V be the set of vertices in P y which are incident to a negative edge. The following are equivalent: () the array y is the prefix array for some partial word, () every cycle in P y which contains exactly one negative edge has at least one vertex which is not in V, and (3) every negative edge of P y connects vertices in two different connected components of P + y [V ]. Proof. First we prove () implies () by contraposition. Assume {i, j} is a negative edge in P y which connects vertices i and j, where i and j lie in the same connected component of P + y [V ]. Then there exists a path, p, in 5

P y + [V ] from i to j. Further suppose w is an indeterminate string which satisfies y. Since each edge in path p is a positive edge, Lemma implies there exists some k such that k is in this path and w[k] is an indeterminate letter. However, k V, so by Lemma 4, w[k] cannot be a hole. Since holes are the only indeterminate letters allowed in a partial word, w is not a partial word. Next we prove () implies (3), again by contraposition. Suppose {i, j} is a negative edge such that i and j are in the same connected component of P y + [V ]. Then there exists a path from j to i which lies in P y + [V ]. Note that all the edges in this path are positive, and all the vertices are in V. Then concatenating {i, j} to this path creates a cycle in P y which contains exactly one negative edge, but whose vertices all are in V. Finally, we prove (3) implies (). Assume every negative edge of P y connects vertices in two different connected components of P y + [V ]. Let C, C,..., C l be the connected components of P y + [V ], and construct a partial word w on the alphabet {a, a,..., a l } by setting w[i] = a j if i C j and w[i] = if i / V. Note that this construction does indeed assign one letter (or hole) to each position of w, and we claim that w satisfies y. Suppose {i, j} is a negative edge in P y. By assumption, i and j are in different connected components of P y + [V ], so w[i] w[j]. Hence this edge is satisfied. Now suppose {i, j} is a positive edge in P y. If i / V, then w[i] =, which implies w[i] w[j] and w satisfies {i, j}. A symmetric argument holds for j / V. Now assume i, j V. This implies i and j are in the same connected component of P y + [V ], so w[i] = w[j], satisfying {i, j}. Therefore w satisfies all edges of P y, proving that y is the prefix array for the partial word w. 5. Constructing partial words for prefix arrays Based upon the construction given in the above proof, we define V (P y ) (or just V if P y is clear from context) to be the set of vertices in P y which are incident to a negative edge. Further, construct the graph C y as follows: make one vertex in C y for each connected component in P + y [V ] and join two vertices in C y if and only if there exists a negative edge in P y between their corresponding components. Figure 6 illustrates this graph construction. If y is the prefix array for some partial word, µ (y) will denote the minimum alphabet size for a partial word satisfying y. Theorem. Let y be the prefix array for some partial word. Then µ (y) = χ(c y ). 6

3 5 4 3 5,3,5 P y P y [V ] Figure 6: Example construction of the graph C y for prefix array y = 63. Proof. Let C, C,..., C l be the connected components of P + y [V ] and assume we have a valid coloring of C y. We treat these colors as letters and construct w using a similar method to the one given in the proof of Theorem. We let w[i] be the color of C k if i C k and let w[i] = otherwise. The proof that w satisfies y follows exactly the last part of the proof of Theorem. Hence µ (y) χ(c y ). Let w be a partial word satisfying y on an alphabet, A, of minimum size. Suppose i and i are in the same connected component of P + y [V ]. Then there exists a path, i = j, j,..., j k = i, of positive edges from i to i such that each vertex in this path is in V. By Lemma 4, w[j l ] must be a regular letter for each l..k. Then, since j l and j l+ are joined by a positive edge for each l..k, it follows that w[j ] = w[j ] = = w[j k ]. Hence w[i] = w[i ]. This implies that all positions of w associated with vertices in a given connected component of P + y [V ] must have the same letter. Now we give a coloring of C y using the letters in A. Color a vertex, v, of C y with a A if there exists some i in the connected component of P + y [V ] represented by v such that w[i] = a. It follows from the above discussion that this coloring operation is well-defined. We claim that this is a valid coloring. Suppose u and v are vertices of C y joined by an edge. This edge corresponds to some negative edge {i, j} in P y, where i is in the connected component of P + y [V ] represented by u and j is in the connected component of P + y [V ] represented by v. Since i and j are connected by a negative edge, it must be that w[i] w[j] which implies u and v have different colors. Hence this is a valid coloring and χ(c y ) µ (y). It is well known that if a graph G has e edges, then χ(g)(χ(g) ) e. We can use this fact to bound µ (y). 7

Corollary 4. Let y be the prefix array for some partial word such that n y = n. Then µ (y). Proof. Recall from Section that P y has at most n negative edges, and since each edge of C y corresponds to at least one negative edge in P y, we know C y also has at most n edges. Further, by Theorem, µ (y) = χ(c y ). µ So, (y)(µ (y) ) = χ(cy)(χ(cy) ) < n. The result follows from algebraic manipulation of the above inequality. We can show that this bound is tight within a constant multiple using Sidon sets. In number theory, a set S = {s, s,..., s m } of natural numbers is a finite Sidon set, named after the Hungarian mathematician Simon Sidon, if the pairwise sums s i + s j, i j, are all different. It is easy to show that Sidon sets have the property that the pairwise differences s i s j, i < j, are also all different. Proposition 3. There exists a prefix array, y, of size n such that µ (y) = ( o()) n. Proof. Erdős and Turán [8, ] showed that there exists a Sidon set with ( o()) n elements such that each element is less than n. Let S = {s, s,..., s m } be such a set, where m = ( o()) n. Define y = y[..n) by { s j if i = s k s j, for some s j, s k S, s j < s k, y[i] = n i otherwise. We show that P y contains an m-clique. Consider s r, s t S, where s r < s t. This implies y[s t s r ] = s r, and since s t s r + s r = s t < n, it follows that {y[s t s r ], s t s r + y[s t s r ]} = {s r, s t } E, where {s r, s t } indicates an edge between the vertices indexed by s r and s t. Moreover, this holds for any pair of elements in S, so the vertices indexed by S form an m-clique in P y. This implies µ (y) m. Now construct a partial word w on the alphabet A = {a, a,..., a m } by w[i] = a j if i = s j S, while w[i] = otherwise. We claim that w satisfies y. Since i + y[i] = n whenever y[i] / S, the only negative edges of P y are of the form {s r, s t } where s r, s t S. Note that w[s r ] = a r a t = w[s t ], so w satisfies all of these negative edges. Moreover, since S is an m-clique in P y, any positive edge must be incident to some vertex i where i / S. Then w[i] =, which matches anything, so this positive edge must be satisfied. Therefore w satisfies y on m letters, implying µ (y) m. 8

5 5 4 4 3 3 Figure 7: Spanning subgraph for array 64 (left) of prefix graph for lengthening 64 (right). Referring to the proof of Proposition 3, the Sidon set {,, 4, 6} determines the prefix array y = 74. Note that Py contains the 4-clique {,, 4, 6}. It follows from Corollary 4 and Proposition 3 that the maximum of the µ (y) s such that y is the prefix array for a partial word of length n is Θ( n), while the maximum of the µ(y) s such that y is a feasible prefix array of size n is Ω( n). 5. Enumerating all prefix arrays of a given size We present an algorithm which enumerates all prefix arrays of size n valid for partial words. Let pref (n) be the number of such prefix arrays. Recall from Theorem that p is a valid prefix array for a partial word if and only if every negative edge in P p connects vertices in two different connected components of P p + [V ]. We call this the CC condition. An array p is a lengthening of an array p if the first p entries of p and p are identical. If p is an array which has some feasible lengthening y, denote by P p the spanning subgraph of P y containing only edges determined by the first p elements of y. Figure 7 gives an example. Let us first give an overview of our algorithm, Algorithm, that constructs all prefix arrays of size n valid for partial words by building arrays one entry at a time. If P p violates the CC condition then P p also violates the CC condition for any lengthening p, so any partial prefix candidate is never lengthened in error by more than one position. When an array of size n satisfying the CC condition is reached, it must be a valid prefix array for some partial word, and all such arrays are eventually reached by our algorithm. Our algorithm builds a tree of height n, an example is shown in Figure 8. Some facts about the tree construction are () every leaf occurs 9

4 3 Figure 8: Tree construction for prefix arrays of size 4 valid for partial words (4 and 4 are not valid). 3 3 3 3 P 4 P 4 P 4 P 4 Figure 9: Constructing array 4. Here P 4, P 4, and P 4 do satisfy the CC condition, but P 4 does not. at depth n (assuming the root is at depth ), () every node has either or as a child, and (3) the set of paths from root to leaf is in bijective correspondence with the set of prefix arrays valid for partial words. Figure 9 provides an example of how our algorithm works. We give the pseudocode for Algorithm. It calls Procedure, which in turn calls Procedure 3. The entry C d [i] gives the positive integer label (if it exists) assigned to vertex i at depth d, and is zero if i has not yet been labeled. The entry F d [i] gives, at depth d, the set of all positive labels j such that some vertex in the component labeled j is connected to a vertex in the ith component by a negative edge. In other words, a set of components which are forbidden from being merged with the component of i. We denote by P p + and Pp the adjacency matrices of P p for its positive and negative edges, respectively. Note that the line reset P p + and Pp in Procedure means to reverse only the changes made by the most recent call to Procedure 3. Theorem. Algorithm prints every prefix array of size n valid for partial

Algorithm Enumerate Prefix Arrays of Size n Valid for Partial Words Require: integer n : initialize n n arrays P p +, and Pp to all zeros : initialize an n-element array p and two n-element collections of n-element arrays C = {C i } n i= to zeros 3: initialize an n-element collection of n-element arrays of sets F = {F i } n i= to empty sets 4: p[] n 5: d 6: IncreaseDepth(p, d, C, F, P + p, P p ) 7: return Procedure IncreaseDepth Require: p, d, C, F, P + p, P p : d d + : for i = to n d do 3: C d C d 4: F d F d 5: p[d] = i 6: if V alidp ref(p, d, C, F, P p +, Pp ) and d < n then 7: IncreaseDepth(p, d, C, F, P p +, Pp ) 8: reset P + p and P p words in lexicographic order exactly once. Proof. The algorithm uses the characterization of valid prefix arrays given in Theorem and attempts to build a prefix array p one entry at a time. If there exists a lengthening of p to a valid prefix array for a partial word, then the algorithm finds it and extends p. If not, then the algorithm never again considers a prefix array starting with p. Procedure serves to reset arrays and adjacency matrices, and try possible additions to p. We say something occurs at depth d in the algorithm if the current array, p, being checked has d elements. To check the CC condition, we use C d and F d. It suffices to check that Procedure 3 determines whether or not p satisfies the CC condition and can be extended, then correctly updates C, F, P p +, and Pp corresponding to p. Suppose we extend our array by appending i to the end. If i < n d then the addition introduces a negative edge into Pp. Line checks that this does not connect vertices in the same labeled connected component of P + [V ].

Procedure 3 ValidPref Require: p, d, C, F, P p +, Pp : i p[d] : if i < n d then 3: if C d [i] = C d [d + i] > then 4: return false 5: Pp [i][d + i] and Pp [d + i][i] 6: if C d [i] = then 7: for j such that P p + [i][j] = do 8: if C d [j] > for some j then 9: C d [i] C d [j] : else : C d [i] max{c d [k] k < n} + : if there exist j < j such that C d [j ] C d [j ] > and F d [C d [j ]] F d [C d [j ]] then 3: return false 4: else 5: for k such that C d [k] = C d [j ] do 6: C d [k] C d [j ] 7: F d [C d [j ]] F d [C d [j ]] F d [C d [j ]] 8: if C d [i + d] = then 9: for j such that P p + [i + d][j] = do : if C d [j] > for some j then : C d [i + d] C d [j] : else 3: C d [i + d] max{c d [k] k < n} + 4: if there exist j < j such that C d [j ] C d [j ] > and F d [C d [j ]] F d [C d [j ]] then 5: return false 6: else 7: for k such that C d [k] = C d [j ] do 8: C d [k] C d [j ] 9: F d [C d [j ]] F d [C d [j ]] F d [C d [j ]] 3: F d [C d [i]] F d [C d [i]] F d [C d [i + d]] 3: for j = to i do 3: if C d [j + d] F d [j] then 33: return false 34: P p + [j][j + d] 35: for k such that C d [k] = C d [j + d] do 36: C d [k] C d [j] 37: F d [C d [j]] F d [C d [j]] F d [C d [j + d]] 38: if d = n then 39: print p 4: return true

After updating Pp we must check whether i and i + d have already been assigned component labels. If they have not, then we must assign labels. Lines 9 do this for i, and Lines 3 work identically for i+d, so we focus our attention on i. If i is connected by a positive edge to a vertex which has already been labeled, then we assign that label to i. Otherwise, assign it a brand new label. Then we check whether any two labeled components connected to it are different. If they are forbidden from being connected then the CC condition is violated and we return false. Otherwise we merge the components and their corresponding F sets. Next we consider each positive edge and check that it satisfies the CC condition (Lines 33 39). Line 34 rules out the possibility of merging components which are not allowed to be joined. Then we update P p + and finally merge the components connected by the positive edge. If we are at depth n, then we have a prefix array of size n which is valid for partial words so we print it. Since p satisfies the CC condition after each lengthening, it is clear that it satisfies it once it reaches length n and thus all arrays which we print are valid prefix arrays for partial words. Moreover, the arrays are printed in increasing lexicographic order so it is clear that no array is printed more than once. Proposition 4. Let p be an array such that p < p[] and p[i] p[] i. If p satisfies the CC condition, then either p or p also satisfy the CC condition. Proof. Let p be an array satisfying our assumptions and set p = k. Construct the prefix graph P of p. There are two cases to consider. First, suppose and p[k ] are both incident to negative edges, so they are both vertices in P + [V ]. If they are in the same connected component, we can append a to p. If they are in different connected components, we can append a to p. Now, suppose either or p[k ] is only incident to positive edges. This vertex does not appear in P + [V ], and the addition of a positive edge does not change this, so we may append a to p without violating the CC condition. Construct a labeled tree T as follows: Label the root n. Assume we have the tree constructed up to depth d. Then for each vertex v at depth d, let p be the array whose ith entry is the ith vertex in the path from the root to v. Create a child of v labeled j if pj satisfies the CC condition. The following connections can be made between T, Algorithm, and the set of prefix arrays of size n valid for partial words: 3

. There is one node in T for each time Procedure 3 returns true. Listing the labels as they are seen for the first time in an in-order traversal of T is identical to listing, in the order that Algorithm calls it, the lengthenings that Procedure 3 returns true on.. Every leaf in T occurs at depth n. Indeed, every node at depth d where d < n satisfies the CC condition, so by Proposition 4 it has at least one lengthening. 3. The set of all paths from root to leaf is in bijective correspondence with the set of prefix arrays of size n valid for partial words. Proposition 5. Algorithm runs in O(n 3 pref (n)) time. Proof. We use the correspondence between the algorithm and the tree T described above. All pref (n) leaves occur at depth n, so the total number of vertices in the tree is bounded above by n pref (n). The time it takes to get from one node to the next is the time it takes to run Procedure 3. Checking the CC condition after the addition of a single positive or negative edge takes O(n) time. Since lengthening an array introduces at most negative and n positive edges to the prefix graph, we conclude that Procedure 3 runs in O(n ) time. Thus, the entire algorithm is O(n 3 pref (n)). Next, we use the following notion to prove a bound for pref (n). Two partial words w and w of length n are p-equivalent if for all i and j such that i j < n we have w[i] w[j] if and only if w [i] w [j]. In other words, w is just a relabeling of w. If two partial words are not p-equivalent, we say they are p-distinct. We start with a lemma. Lemma 5. The number of p-distinct partial words of length n with h holes and µ letters is ( ){ n n h } { h µ, where n } µ denotes a Stirling number of the second kind. Proof. We borrow from [5] and use the infinite standard alphabet, Λ = {λ, λ,..., λ µ,...}, which has subalphabets Λ µ = {λ, λ,..., λ µ } for each integer µ. The standard alphabet uses the natural ordering: λ i < λ j for all i < j. In addition, we consider < λ. We call a partial word w p-canonical if w Λ and, for every j, no λ j appears before all of λ,..., λ j have appeared at least once. For example, λ λ λ λ 3 λ 3 is p- canonical, but λ λ λ λ 4 is not because λ 4 appears before λ 3 has appeared. It is important to note that every partial word is p-equivalent to exactly one p-canonical partial word. 4

For nonnegative integers h, µ and positive integer n, we extend a definition of [5] to define p [µ, n, h] as the number of p-distinct partial words of length n that use exactly µ letters and have h holes. For each p-canonical word w of length n h that uses exactly µ letters, there are ( n h) partial words resulting from inserting h holes into w. For any p-canonical word w w with the same length and letters used, adding h holes results in partial words that are distinct from those arising out of w. Also, every p-canonical word of length n using exactly µ letters with h holes can be generated through this process. Thus, p [µ, n, h] = ( n } { h) p [µ, n h, ]. Moreover n µ} from [5], p [µ, n, ] = { n µ kind. Therefore, p [µ, n, h] = ( n h We now prove our bound., where ) { n h µ }. Proposition 6. For sufficiently large n, pref (n) n { n+ is a Stirling number of the second n + where { n+ } n + denotes a Stirling number of the second kind. Proof. By Corollary 4, any prefix array valid for partial words can be satisfied by a partial word with at most letters. Partial words which n are p-equivalent have the same prefix array, so different prefix arrays are necessarily p-distinct. We may bound the number of prefix arrays valid for n partial words by the number of p-distinct partial words on at most letters. By Lemma 5, the number of p-distinct partial words of length n with h holes and µ letters is ( ){ n n h } h µ. Summing over all possible numbers of holes we have n µ ( n n h } h= h){ µ = n ( n ){ j { j=µ j µ} = n+ µ+}. n Consider p-distinct partial words using less than letters. The following facts about Stirling numbers are useful. First, for sufficiently large µ and n we have { } n µ < µ n µ!. Second, for fixed n, { n µ} is a unimodal sequence n with mode asympototically approaching log n. Thus for sufficiently large n, we have { n+ } { n+ } n for all j <. Summing over each possible n + j number of letters and using the unimodality of Stirling numbers, pref (n) n } { µ= n n+ }. { n+ µ+ }, n + 5