Range LCP

  • Amihood Amir
  • Alberto Apostolico
  • Gad M. Landau
  • Avivit Levy
  • Moshe Lewenstein
  • Ely Porat
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7074)


In this paper, we define the Range LCP problem as follows. Preprocess a string S, of length n, to enable efficient solutions of the following query:

Given \([i,j],\ \ 0< i \leq j \leq n\), compute max ℓ, k ∈ {i,…,j} LCP(S , S k ), where LCP(S , S k ) is the length of the longest common prefix of the suffixes of S starting at locations ℓ and k. This is a natural generalization of the classical LCP problem.

Surprisingly, while it is known how to preprocess a string in linear time to enable LCP computation of two suffixes in constant time, this seems quite difficult in the Range LCP problem. It is trivial to answer such queries in time O(|j − i|2) after a linear-time preprocessing and easy to show an O(1) query algorithm after an O(|S|2) time preprocessing. We provide algorithms that solve the problem with the following complexities:

  1. 1

    Preprocessing Time: O(|S|), Space: O(|S|), Query Time: O(|j − i|loglogn).

  2. 2

    Preprocessing Time: no preprocessing, Space: O(|j − i|log|j − i|), Query Time: O(|j − i|log|j − i|). However, the query just gives the pairs with the longest LCP, not the LCP itself.

  3. 3

    Preprocessing Time: O(|S|log2 |S|), Space: O(|S|log1 + ε |S|) for arbitrary small constant ε, Query Time: O(loglog|S|).



Query Time Query Algorithm Preprocessing Time Succinct Representation Marked Leaf 
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.
    Apostolico, A., Preparata, F.P.: Optimal off-line detection of repetitions in a string. Theoretical Computer Science 22, 297–315 (1983)MathSciNetCrossRefzbMATHGoogle Scholar
  2. 2.
    Berkman, O., Breslauer, D., Galil, Z., Schieber, B., Vishkin, U.: Highly parallelizable problems. In: Proc. 21st ACM Symposium on Theory of Computation, pp. 309–319 (1989)Google Scholar
  3. 3.
    Chan, T.M., Larsen, K.G., Pǎtraşcu, M.: Orthogonal range searching on the ram, revisited. In: Proc. 27th ACM Symposium on Computational Geometry (SoCG), pp. 1–10 (2011)Google Scholar
  4. 4.
    Cormode, G., Muthukrishnan, S.: Substring compression problems. In: Proc. 16th annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pp. 321–330 (2005)Google Scholar
  5. 5.
    Farach, M.: Optimal suffix tree construction with large alphabets. In: Proc. 38th IEEE Symposium on Foundations of Computer Science, pp. 137–143 (1997)Google Scholar
  6. 6.
    Harel, D., Tarjan, R.E.: Fast algorithms for finding nearest common ancestor. Journal of Computer and System Science 13, 338–355 (1984)MathSciNetzbMATHGoogle Scholar
  7. 7.
    Iacono, J., Özkan, Ö.: Mergeable Dictionaries. In: Abramsky, S., Gavoille, C., Kirchner, C., Meyer auf der Heide, F., Spirakis, P.G. (eds.) ICALP 2010. LNCS, Part I, vol. 6198, pp. 164–175. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  8. 8.
    Kärkkäinen, J., Sanders, P.: Simple Linear Work Suffix Array Construction. In: Baeten, J.C.M., Lenstra, J.K., Parrow, J., Woeginger, G.J. (eds.) ICALP 2003. LNCS, vol. 2719, pp. 943–955. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  9. 9.
    Kasai, T., Lee, G., Arimura, H., Arikawa, S., Park, K.: Linear-Time Longest-Common-Prefix Computation in Suffix Arrays and Its Applications. In: Amir, A., Landau, G.M. (eds.) CPM 2001. LNCS, vol. 2089, pp. 181–192. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  10. 10.
    Keller, O., Kopelowitz, T., Landau, S., Lewenstein, M.: Generalized Substring Compression. In: Kucherov, G., Ukkonen, E. (eds.) CPM 2009 Lille. LNCS, vol. 5577, pp. 26–38. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  11. 11.
    Landau, G.M., Vishkin, U.: Fast parallel and serial approximate string matching. Journal of Algorithms 10(2), 157–169 (1989)MathSciNetCrossRefzbMATHGoogle Scholar
  12. 12.
    Lempel, A., Ziv, J.: On the complexity of finite sequences. IEEE Transactions on Information Theory 22, 75–81 (1976)MathSciNetCrossRefzbMATHGoogle Scholar
  13. 13.
    McCreight, E.M.: A space-economical suffix tree construction algorithm. J. of the ACM 23, 262–272 (1976)MathSciNetCrossRefzbMATHGoogle Scholar
  14. 14.
    Ukkonen, E.: On-line construction of suffix trees. Algorithmica 14, 249–260 (1995)MathSciNetCrossRefzbMATHGoogle Scholar
  15. 15.
    van Emde Boas, P., Kaas, R., Zijlstra, E.: Design and implementation of an efficient priority queue. Mathematical Systems Theory 10, 99–127 (1977)MathSciNetCrossRefzbMATHGoogle Scholar
  16. 16.
    Weiner, P.: Linear pattern matching algorithm. In: Proc. 14 IEEE Symposium on Switching and Automata Theory, pp. 1–11 (1973)Google Scholar
  17. 17.
    Yuan, H., Atallah, M.J.: Data structures for range minimum queries in multidimensional arrays. In: Proc. 21st ACM-SIAM Symposium on Discrete Algorithms (SODA), pp. 150–160 (2010)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Amihood Amir
    • 1
    • 2
  • Alberto Apostolico
    • 3
    • 4
  • Gad M. Landau
    • 5
    • 6
  • Avivit Levy
    • 7
    • 8
  • Moshe Lewenstein
    • 1
  • Ely Porat
    • 1
  1. 1.Department of Computer ScienceBar-Ilan UniversityRamat-GanIsrael
  2. 2.Department of Computer ScienceJohns Hopkins UniversityBaltimoreUSA
  3. 3.College of ComputingGeorgia Institute of TechnologyAtlantaUSA
  4. 4.Dipartimento di Ingegneria dell’ InformazioneUniversità diPadovaPadovaItaly
  5. 5.Department of Computer ScienceUniversity of HaifaMount CarmelIsrael
  6. 6.Department of Computer Science and EngineeringPolytechnic Institute of New York UniversityBrooklynUSA
  7. 7.Department of Software EngineeringShenkar CollegeRamat-GanIsrael
  8. 8.CRIHaifa UniversityMount CarmelIsrael

Personalised recommendations