Practical Algorithms for the Longest Common Extension Problem

  • Authors:
  • Lucian Ilie;Liviu Tinta

  • Affiliations:
  • Department of Computer Science, University of Western Ontario, London, Canada N6A 5B7;Department of Computer Science, University of Western Ontario, London, Canada N6A 5B7

  • Venue:
  • SPIRE '09 Proceedings of the 16th International Symposium on String Processing and Information Retrieval
  • Year:
  • 2009

Quantified Score

Hi-index 0.00

Visualization

Abstract

The Longest Common Extension problem considers a string s and computes, for each of a number of pairs (i ,j ), the longest substring of s that starts at both i and j . It appears as a subproblem in many fundamental string problems and can be solved by linear-time preprocessing of the string that allows (worst-case) constant-time computation for each pair. The two known approaches use powerful algorithms: either constant-time computation of the Lowest Common Ancestor in trees or constant-time computation of Range Minimum Queries (RMQ) in arrays. We show here that, from practical point of view, such complicated approaches are not needed. We give two very simple algorithms for this problem that require no preprocessing. The first needs only the string and is significantly faster than all previous algorithms on the average. The second combines the first with a direct RMQ computation on the Longest Common Prefix array. It takes advantage of the superior speed of the cache memory and is the fastest on virtually all inputs.