A Linear-Space Data Structure for Range-LCP Queries in Poly-Logarithmic Time

  • Paniz Abedin
  • Arnab Ganguly
  • Wing-Kai Hon
  • Yakov Nekrich
  • Kunihiko Sadakane
  • Rahul Shah
  • Sharma V. ThankachanEmail author
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10976)


Let \(\mathsf {T}[1,n]\) be a text of length n and \(\mathsf {T}[i,n]\) be the suffix starting at position i. Also, for any two strings X and Y, let \(\mathsf {LCP}(X, Y)\) denote their longest common prefix. The range-LCP of \(\mathsf {T}\) w.r.t. a range \([\alpha ,\beta ]\), where \(1\le \alpha < \beta \le n\) is Amir et al. [ISAAC 2011] introduced the indexing version of this problem, where the task is to build a data structure over \(\mathsf {T}\), so that \(\mathsf {rlcp}(\alpha ,\beta )\) for any query range \([\alpha ,\beta ]\) can be reported efficiently. They proposed an \(O(n\log ^{1+\epsilon } n)\) space structure with query time \(O(\log \log n)\), and a linear space (i.e., O(n) words) structure with query time \(O(\delta \log \log n)\), where \(\delta = \beta -\alpha +1\) is the length of the input range and \(\epsilon > 0\) is an arbitrarily small constant. Later, Patil et al. [SPIRE 2013] proposed another linear space structure with an improved query time of \(O(\sqrt{\delta }\log ^{\epsilon } \delta )\). This poses an interesting question, whether it is possible to answer \(\mathsf {rlcp}(\cdot ,\cdot )\) queries in poly-logarithmic time using a linear space data structure. In this paper, we settle this question by presenting an O(n) space data structure with query time \(O(\log ^{1+\epsilon } n)\) and construction time \(O(n\log n)\).



This research is supported in part by the U.S. NSF under the grants CCF-1703489 and CCF-1527435, and the Taiwan Ministry of Science and Technology under the grant 105-2221-E-007-040-MY3.


  1. 1.
    Amir, A., Apostolico, A., Landau, G.M., Levy, A., Lewenstein, M., Porat, E.: Range LCP. In: Asano, T., Nakano, S., Okamoto, Y., Watanabe, O. (eds.) ISAAC 2011. LNCS, vol. 7074, pp. 683–692. Springer, Heidelberg (2011). Scholar
  2. 2.
    Amir, A., Apostolico, A., Landau, G.M., Levy, A., Lewenstein, M., Porat, E.: Range LCP. J. Comput. Syst. Sci. 80(7), 1245–1253 (2014)MathSciNetCrossRefGoogle Scholar
  3. 3.
    Amir, A., Lewenstein, M., Thankachan, S.V.: Range LCP queries revisited. In: Iliopoulos, C., Puglisi, S., Yilmaz, E. (eds.) SPIRE 2015. LNCS, vol. 9309, pp. 350–361. Springer, Cham (2015). Scholar
  4. 4.
    Chan, T.M., Larsen, K.G., Patrascu, M.: Orthogonal range searching on the RAM, revisited. In: Symposium on Computational Geometry, pp. 1–10 (2011)Google Scholar
  5. 5.
    Chazelle, B.: A functional approach to data structures and its use in multidimensional searching. SIAM J. Comput. 17(3), 427–462 (1988)MathSciNetCrossRefGoogle Scholar
  6. 6.
    Cormode, G., Muthukrishnan, S.: Substring compression problems. In: Proceedings of the Sixteenth Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 321–330. Society for Industrial and Applied Mathematics (2005)Google Scholar
  7. 7.
    Farach, M., Muthukrishnan, S.: Perfect hashing for strings: formalization and algorithms. In: Hirschberg, D., Myers, G. (eds.) CPM 1996. LNCS, vol. 1075, pp. 130–140. Springer, Heidelberg (1996). Scholar
  8. 8.
    Fischer, J., Heun, V.: Space-efficient preprocessing schemes for range minimum queries on static arrays. SIAM J. Comput. 40(2), 465–492 (2011)MathSciNetCrossRefGoogle Scholar
  9. 9.
    Gagie, T., Karhu, K., Navarro, G., Puglisi, S.J., Sirén, J.: Document listing on repetitive collections. In: Fischer, J., Sanders, P. (eds.) CPM 2013. LNCS, vol. 7922, pp. 107–119. Springer, Heidelberg (2013). Scholar
  10. 10.
    Gawrychowski, P., Lewenstein, M., Nicholson, P.K.: Weighted ancestors in suffix trees. In: Schulz, A.S., Wagner, D. (eds.) ESA 2014. LNCS, vol. 8737, pp. 455–466. Springer, Heidelberg (2014). Scholar
  11. 11.
    Harel, D., Tarjan, R.E.: Fast algorithms for finding nearest common ancestors. SIAM J. Comput. 13(2), 338–355 (1984)MathSciNetCrossRefGoogle Scholar
  12. 12.
    Keller, O., Kopelowitz, T., Feibish, S.L., Lewenstein, M.: Generalized substring compression. Theor. Comput. Sci. 525, 42–54 (2014)MathSciNetCrossRefGoogle Scholar
  13. 13.
    Lewenstein, M.: Orthogonal range searching for text indexing. In: Brodnik, A., López-Ortiz, A., Raman, V., Viola, A. (eds.) Space-Efficient Data Structures, Streams, and Algorithms. LNCS, vol. 8066, pp. 267–302. Springer, Heidelberg (2013). Scholar
  14. 14.
    Nekrich, Y., Navarro, G.: Sorted range reporting. In: Fomin, F.V., Kaski, P. (eds.) SWAT 2012. LNCS, vol. 7357, pp. 271–282. Springer, Heidelberg (2012). Scholar
  15. 15.
    Patil, M., Shah, R., Thankachan, S.V.: Faster range LCP queries. In: Kurland, O., Lewenstein, M., Porat, E. (eds.) SPIRE 2013. LNCS, vol. 8214, pp. 263–270. Springer, Cham (2013). Scholar
  16. 16.
    Patil, M., Thankachan, S.V., Shah, R., Nekrich, Y., Vitter, J.S.: Categorical range maxima queries. In: Proceedings of the 33rd ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems, PODS 2014, 22–27 June 2014, Snowbird, UT, USA, pp. 266–277 (2014)Google Scholar
  17. 17.
    Sleator, D.D., Tarjan, R.E.: A data structure for dynamic trees. In: Proceedings of the 13th Annual ACM Symposium on Theory of Computing, 11–13 May 1981, Milwaukee, Wisconsin, USA, pp. 114–122 (1981)Google Scholar
  18. 18.
    Weiner, P.: Linear pattern matching algorithms. In: SWAT, pp. 1–11 (1973)Google Scholar
  19. 19.
    Willard, D.E.: Log-logarithmic worst-case range queries are possible in space theta(n). Inf. Process. Lett. 17(2), 81–84 (1983)CrossRefGoogle Scholar

Copyright information

© This is a U.S. government work and its text is not subject to copyright protection in the United States; however, its text may be subject to foreign copyright protection 2018

Authors and Affiliations

  • Paniz Abedin
    • 1
  • Arnab Ganguly
    • 2
  • Wing-Kai Hon
    • 3
  • Yakov Nekrich
    • 4
  • Kunihiko Sadakane
    • 5
  • Rahul Shah
    • 6
    • 7
  • Sharma V. Thankachan
    • 1
    Email author
  1. 1.Department of Computer ScienceUniversity of Central FloridaOrlandoUSA
  2. 2.Department of Computer ScienceUniversity of Wisconsin - WhitewaterWhitewaterUSA
  3. 3.Department of Computer ScienceNational Tsing Hua UniversityHsinchuTaiwan
  4. 4.Cheriton School of Computer ScienceUniversity of WaterlooWaterlooCanada
  5. 5.Department of Computer ScienceThe University of TokyoTokyoJapan
  6. 6.Department of Computer ScienceLouisiana State UniversityBaton RougeUSA
  7. 7.National Science Foundation (NSF)AlexandriaUSA

Personalised recommendations