Approximate Pattern Matching with the L 1, L 2 and L ∞ Metrics

  • Authors:
  • Ohad Lipsky;Ely Porat

  • Affiliations:
  • Bar-Ilan University, Department of Computer Science, 52900, Ramat-Gan, Israel;Bar-Ilan University, Department of Computer Science, 52900, Ramat-Gan, Israel

  • Venue:
  • Algorithmica
  • Year:
  • 2011

Quantified Score

Hi-index 0.00

Visualization

Abstract

Given an alphabet Σ={1,2,…,|Σ|} text string T∈Σn and a pattern string P∈Σm , for each i=1,2,…,n−m+1 define L p (i) as the p-norm distance when the pattern is aligned below the text and starts at position i of the text. The problem of pattern matching with L p distance is to compute L p (i) for every i=1,2,…,n−m+1. We discuss the problem for d=1,2,∞. First, in the case of L 1 matching (pattern matching with an L 1 distance) we show a reduction of the string matching with mismatches problem to the L 1 matching problem and we present an algorithm that approximates the L 1 matching up to a factor of 1+ε, which has an $O(\frac{1}{\varepsilon^{2}}n\log m\log|\Sigma|)$ run time. Then, the L 2 matching problem (pattern matching with an L 2 distance) is solved with a simple O(nlog m) time algorithm. Finally, we provide an algorithm that approximates the L ∞ matching up to a factor of 1+ε with a run time of $O(\frac{1}{\varepsilon}n\log m\log|\Sigma|)$. We also generalize the problem of String Matching with mismatches to have weighted mismatches and present an O(nlog 4 m) algorithm that approximates the results of this problem up to a factor of O(log m) in the case that the weight function is a metric.