Validating the Knuth-Morris-Pratt Failure Function, Fast and Online

  • Authors:
  • Paweł Gawrychowski;Artur Jeż;Łukasz Jeż

  • Affiliations:
  • Max Planck Institute for Computer Science, Saarbrücken, Germany and Institute of Computer Science, University of Wrocław, Wrocław, Poland;Max Planck Institute for Computer Science, Saarbrücken, Germany and Institute of Computer Science, University of Wrocław, Wrocław, Poland;Institute of Computer Science, University of Wrocław, Wrocław, Poland and Blavatnik School of Computer Science, Tel Aviv University, Tel Aviv, Israel

  • Venue:
  • Theory of Computing Systems
  • Year:
  • 2014

Quantified Score

Hi-index 0.00

Visualization

Abstract

Let $\pi'_{w}$ denote the failure function of the Knuth-Morris-Pratt algorithm for a word w. In this paper we study the following problem: given an integer array $A'[1 \mathinner {\ldotp \ldotp }n]$ , is there a word w over an arbitrary alphabet Σ such that $A'[i]=\pi'_{w}[i]$ for all i? Moreover, what is the minimum cardinality of Σ required? We give an elementary and self-contained $\mathcal{O}(n\log n)$ time algorithm for this problem, thus improving the previously known solution (Duval et al. in Conference in honor of Donald E. Knuth, 2007), which had no polynomial time bound. Using both deeper combinatorial insight into the structure of 驴驴 and advanced algorithmic tools, we further improve the running time to $\mathcal{O}(n)$ .