A Black Box for Online Approximate Pattern Matching

  • Raphaël Clifford
  • Klim Efremenko
  • Benny Porat
  • Ely Porat
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5029)


We present a deterministic black box solution for online approximate matching. Given a pattern of length m and a streaming text of length n that arrives one character at a time, the task is to report the distance between the pattern and a sliding window of the text as soon as the new character arrives. Our solution requires \(O(\Sigma_{j=1}^{\log_2{m}} T(n,2^{j-1})/n)\) time for each input character, where T(n,m) is the total running time of the best offline algorithm. The types of approximation that are supported include exact matching with wildcards, matching under the Hamming norm, approximating the Hamming norm, k-mismatch and numerical measures such as the L 2 and L 1 norms. For these examples, the resulting online algorithms take O(log2 m), \(O(\sqrt{m\log{m}})\), O(log2 m/ε 2), \(O(\sqrt{k \log k} \log{m})\), O(log2 m) and \(O(\sqrt{m\log{m}})\) time per character respectively. The space overhead is O(m) which we show is optimal.


Fast Fourier Transform Online Algorithm String Match Input Character Approximate Match 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Abrahamson, K.: Generalized string matching. SIAM journal on Computing 16(6), 1039–1051 (1987)zbMATHCrossRefMathSciNetGoogle Scholar
  2. 2.
    Amir, A., Farach, M.: Efficient 2-dimensional approximate matching of half-rectangular figures. Information and Computation 118(1), 1–11 (1995)zbMATHCrossRefMathSciNetGoogle Scholar
  3. 3.
    Amir, A., Lipsky, O., Porat, E., Umanski, J.: Approximate matching in the L 1 metric. In: Apostolico, A., Crochemore, M., Park, K. (eds.) CPM 2005. LNCS, vol. 3537, pp. 91–103. Springer, Heidelberg (2005)Google Scholar
  4. 4.
    Amir, A., Lewenstein, M., Porat, E.: Faster algorithms for string matching with k mismatches. J. Algorithms 50(2), 257–275 (2004)zbMATHCrossRefMathSciNetGoogle Scholar
  5. 5.
    Atallah, M.J.: Faster image template matching in the sum of the absolute value of differences measure. IEEE Transactions on Image Processing 10(4), 659–663 (2001)zbMATHCrossRefMathSciNetGoogle Scholar
  6. 6.
    Clifford, P., Clifford, R.: Simple deterministic wildcard matching. Information Processing Letters 101(2), 53–54 (2007)CrossRefMathSciNetGoogle Scholar
  7. 7.
    Clifford, P., Clifford, R., Iliopoulos, C.S.: Faster algorithms for δ,γ-matching and related problems. In: Apostolico, A., Crochemore, M., Park, K. (eds.) CPM 2005. LNCS, vol. 3537, pp. 68–78. Springer, Heidelberg (2005)Google Scholar
  8. 8.
    Clifford, R., Iliopoulos, C.: String algorithms in music analysis. Soft Computing 8(9), 597–603 (2004)zbMATHCrossRefGoogle Scholar
  9. 9.
    Clifford, R., Efremenko, K., Porat, E., Rothschild, A.: k-mismatch with don’t cares. In: Arge, L., Hoffmann, M., Welzl, E. (eds.) ESA 2007. LNCS, vol. 4698, pp. 151–162. Springer, Heidelberg (2007)Google Scholar
  10. 10.
    Clifford, R., Porat, E.: A filtering algorithm for k-mismatch with don’t cares. In: Ziviani, N., Baeza-Yates, R. (eds.) SPIRE 2007. LNCS, vol. 4726, pp. 130–136. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  11. 11.
    Cormen, T.H., Leiserson, C.E., Rivest, R.L.: Introduction to Algorithms. MIT Press, Cambridge (1990)Google Scholar
  12. 12.
    Cole, R., Hariharan, R.: Verifying candidate matches in sparse and wildcard matching. In: Proceedings of the Annual ACM Symposium on Theory of Computing, pp. 592–601 (2002)Google Scholar
  13. 13.
    Fischer, M., Paterson, M.: String matching and other products. In: Karp, R. (ed.) Proceedings of the 7th SIAM-AMS Complexity of Computation, pp. 113–125 (1974)Google Scholar
  14. 14.
    Henzinger, M.R., Raghavan, P., Rajagopalan, S.: Computing on data streams. In: External memory algorithms, pp. 107–118. American Mathematical Society, Boston (1999)Google Scholar
  15. 15.
    Indyk, P.: Faster algorithms for string matching problems: Matching the convolution bound. In: Proceedings of the 38th Annual Symposium on Foundations of Computer Science, pp. 166–173 (1998)Google Scholar
  16. 16.
    Kalai, A.: Efficient pattern-matching with don’t cares. In: Proceedings of the 13th Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 655–656 (2002)Google Scholar
  17. 17.
    Kosaraju, S.R.: Efficient string matching (1987) (manuscript)Google Scholar
  18. 18.
    Landau, G.M., Vishkin, U.: Efficient string matching with k mismatches. Theoretical Computer Science 43, 239–249 (1986)zbMATHCrossRefMathSciNetGoogle Scholar
  19. 19.
    Lipsky, O., Porat, E.: Approximate matching in the L ∞  metric. In: String Processing and Information Retrieval, 12th International Symposium (SPIRE 2005). LNCS, pp. 331–334. Springer, Heidelberg (2005)Google Scholar
  20. 20.
    Muthukrishnan, S.: Data streams: algorithms and applications. In: SODA 2003: Proceedings of the fourteenth annual ACM-SIAM symposium on Discrete algorithms, p. 413 (2003)Google Scholar
  21. 21.
    Tamm, U.: Communication complexity of sum-type functions invariant under translation. Inf. Comput. 116(2), 162–173 (1995)zbMATHCrossRefMathSciNetGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2008

Authors and Affiliations

  • Raphaël Clifford
    • 1
  • Klim Efremenko
    • 2
  • Benny Porat
    • 3
  • Ely Porat
    • 3
  1. 1.Dept. of Computer ScienceUniversity of BristolBristolUK
  2. 2.Dept. of Computer Science, Dept. of Computer Science and Applied MathematicsBar-Ilan University, Weizman InstituteRamat-GanIsrael
  3. 3.Dept. of Computer ScienceBar-Ilan UniversityRamat-GanIsrael

Personalised recommendations