Table of Contents
Fetching ...

Closed Repeats

Dmitry Kosolobov

Abstract

Much research in stringology focuses on structures that can, in a way, ``grasp'' repeats (substrings that occur multiple times) as, for example, the so-called runs, a.k.a. maximal repetitions, compactly describe all tandem repeats. In this paper we introduce closed repeats: given a string $s$, its non-empty substring $s[i\,..\,j]$ is a right (left) closed repeat if its closest occurrence $s[i'\,..\,j']$ with $i' > i$ cannot be ``extended'' to the right (respectively, left) matching $s[j{+}1] = s[j'{+}1]$ (respectively, $s[i{-}1] = s[i'{-}1]$); the repeat is closed if it is both left and right closed. We note that the closed repeats correspond to the maximal closed substrings recently proposed by Badkobeh et al. and they include all runs as a special case. We prove that the number of right/left closed repeats is $O(n \log n)$, where $n$ is the length of $s$, and we show that this bound is tight. The (right/left) closed repeats can be computed in the optimal time $O(n\log n)$; as we prove, the computation time cannot be lower than $Ω(n\logσ)$ over a general ordered alphabet of size $σ$ even when the number of the closed repeats is $O(n)$. As an application, we describe data structures using the closed repeats for a number of substring queries: finding the period of the substring provided it is ``periodic'', finding the longest repeat in the substring, computing the rightmost LZ77 parsing of the substring.

Closed Repeats

Abstract

Much research in stringology focuses on structures that can, in a way, ``grasp'' repeats (substrings that occur multiple times) as, for example, the so-called runs, a.k.a. maximal repetitions, compactly describe all tandem repeats. In this paper we introduce closed repeats: given a string , its non-empty substring is a right (left) closed repeat if its closest occurrence with cannot be ``extended'' to the right (respectively, left) matching (respectively, ); the repeat is closed if it is both left and right closed. We note that the closed repeats correspond to the maximal closed substrings recently proposed by Badkobeh et al. and they include all runs as a special case. We prove that the number of right/left closed repeats is , where is the length of , and we show that this bound is tight. The (right/left) closed repeats can be computed in the optimal time ; as we prove, the computation time cannot be lower than over a general ordered alphabet of size even when the number of the closed repeats is . As an application, we describe data structures using the closed repeats for a number of substring queries: finding the period of the substring provided it is ``periodic'', finding the longest repeat in the substring, computing the rightmost LZ77 parsing of the substring.
Paper Structure (7 sections, 5 theorems, 1 equation, 1 figure)

This paper contains 7 sections, 5 theorems, 1 equation, 1 figure.

Key Result

Theorem 1

Any string of length $n$ contains at most $O(n\log n)$ left closed repeats and right closed repeats.

Figures (1)

  • Figure 1: A schematic depiction of a string $s[i\,..\, i{+}\ell)$ with a period $p$ such that $2p \le \ell$. The "hills" depict the substrings $u = s[i\,..\, i{+}p) = s[i{+}p\,..\, i{+}2p) =\cdots$ As is shown, whenever the border $s[i{+}p\,..\, i{+}\ell)$ occurs at a position between $i$ and $i + p$, the string $u$ must be equal to a non-trivial cyclic rotation of itself.

Theorems & Definitions (10)

  • Example
  • Theorem 1
  • proof
  • Theorem 2
  • proof
  • Lemma 1
  • Lemma 2
  • proof
  • Theorem 3
  • proof