Advertisement

How to Answer a Small Batch of RMQs or LCA Queries in Practice

  • Mai Alzamel
  • Panagiotis CharalampopoulosEmail author
  • Costas S. Iliopoulos
  • Solon P. Pissis
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10765)

Abstract

In the Range Minimum Query (RMQ) problem, we are given an array A of n numbers and we are asked to answer queries of the following type: for indices i and j between 0 and \(n-1\), query \(\text {RMQ}_A(i,j)\) returns the index of a minimum element in the subarray \(A[i\mathinner {.\,.}j]\). Answering a small batch of RMQs is a core computational task in many real-world applications, in particular due to the connection with the Lowest Common Ancestor (LCA) problem. With small batch, we mean that the number q of queries is o(n) and we have them all at hand. It is therefore not relevant to build an \(\varOmega (n)\)-sized data structure or spend \(\varOmega (n)\) time to build a more succinct one. It is well-known, among practitioners and elsewhere, that these data structures for online querying carry high constants in their pre-processing and querying time. We would thus like to answer this batch efficiently in practice. With efficiently in practice, we mean that we (ultimately) want to spend \(n + \mathcal {O}(q)\) time and \(\mathcal {O}(q)\) space. We write n to stress that the number of operations per entry of A should be a very small constant. Here we show how existing algorithms can be easily modified to satisfy these conditions. The presented experimental results highlight the practicality of this new scheme. The most significant improvement obtained is for answering a small batch of LCA queries. A library implementation of the presented algorithms is made available.

References

  1. 1.
    Afshani, P., Sitchinava, N.: I/O-efficient range minima queries. In: Ravi, R., Gørtz, I.L. (eds.) SWAT 2014. LNCS, vol. 8503, pp. 1–12. Springer, Cham (2014).  https://doi.org/10.1007/978-3-319-08404-6_1CrossRefGoogle Scholar
  2. 2.
    Arge, L., Fischer, J., Sanders, P., Sitchinava, N.: On (dynamic) range minimum queries in external memory. In: Dehne, F., Solis-Oba, R., Sack, J.-R. (eds.) WADS 2013. LNCS, vol. 8037, pp. 37–48. Springer, Heidelberg (2013).  https://doi.org/10.1007/978-3-642-40104-6_4CrossRefGoogle Scholar
  3. 3.
    Athar, T., Barton, C., Bland, W., Gao, J., Iliopoulos, C.S., Liu, C., Pissis, S.P.: Fast circular dictionary-matching algorithm. Math. Struct. Comput. Sci. 27(2), 143–156 (2017)MathSciNetCrossRefGoogle Scholar
  4. 4.
    Bender, M.A., Farach-Colton, M.: The LCA problem revisited. In: Gonnet, G.H., Viola, A. (eds.) LATIN 2000. LNCS, vol. 1776, pp. 88–94. Springer, Heidelberg (2000).  https://doi.org/10.1007/10719839_9CrossRefGoogle Scholar
  5. 5.
    Bender, M.A., Farach-Colton, M., Pemmasani, G., Skiena, S., Sumazin, P.: Lowest common ancestors in trees and directed acyclic graphs. J. Algorithms 57(2), 75–94 (2005)MathSciNetCrossRefGoogle Scholar
  6. 6.
    Berkman, O., Vishkin, U.: Recursive star-tree parallel data structure. SIAM J. Comput. 22(2), 221–242 (1993)MathSciNetCrossRefGoogle Scholar
  7. 7.
    Crochemore, M., Hancart, C., Lecroq, T.: Algorithms on Strings. Cambridge University Press, Cambridge (2007)CrossRefGoogle Scholar
  8. 8.
    Ferrada, H., Navarro, G.: Improved range minimum queries. J. Discret. Algorithms 43, 72–80 (2016)MathSciNetCrossRefGoogle Scholar
  9. 9.
    Fischer, J., Heun, V.: Theoretical and practical improvements on the RMQ-problem, with applications to LCA and LCE. In: Lewenstein, M., Valiente, G. (eds.) CPM 2006. LNCS, vol. 4009, pp. 36–48. Springer, Heidelberg (2006).  https://doi.org/10.1007/11780441_5CrossRefGoogle Scholar
  10. 10.
    Gabow, H.N., Bentley, J.L., Tarjan, R.E.: Scaling and related techniques for geometry problems. In: STOC 1984, pp. 135–143. ACM (1984)Google Scholar
  11. 11.
    Gabow, H.N., Tarjan, R.E.: A linear-time algorithm for a special case of disjoint set union. J. Comput. Syst. Sci. 30(2), 209–221 (1985)MathSciNetCrossRefGoogle Scholar
  12. 12.
    Geary, R.F., Rahman, N., Raman, R., Raman, V.: A simple optimal representation for balanced parentheses. Theoret. Comput. Sci. 368(3), 231–246 (2006)MathSciNetCrossRefGoogle Scholar
  13. 13.
    Gog, S., Beller, T., Moffat, A., Petri, M.: From theory to practice: plug and play with succinct data structures. In: Gudmundsson, J., Katajainen, J. (eds.) SEA 2014. LNCS, vol. 8504, pp. 326–337. Springer, Cham (2014).  https://doi.org/10.1007/978-3-319-07959-2_28CrossRefGoogle Scholar
  14. 14.
    Harel, D., Tarjan, R.E.: Fast algorithms for finding nearest common ancestors. SIAM J. Comput. 13(2), 338–355 (1984)MathSciNetCrossRefGoogle Scholar
  15. 15.
    Ilie, L., Navarro, G., Tinta, L.: The longest common extension problem revisited and applications to approximate string searching. J. Discret. Algorithms 8(4), 418–428 (2010)MathSciNetCrossRefGoogle Scholar
  16. 16.
    Iliopoulos, C., Mchugh, J., Peterlongo, P., Pisanti, N., Rytter, W., Sagot, M.-F.: A first approach to finding common motifs with gaps. Int. J. Found. Comput. Sci. 16(6), 1145–1155 (2005)MathSciNetCrossRefGoogle Scholar
  17. 17.
    Kociumaka, T., Pissis, S.P., Radoszewski, J.: Pattern matching and consensus problems on weighted sequences and profiles. In: ISAAC 2016. LIPIcs, vol. 64, pp. 46:1–46:12. Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik (2016)Google Scholar
  18. 18.
    Mäkinen, V., Belazzougui, D., Cunial, F., Tomescu, A.I.: Genome-Scale Algorithm Design: Biological Sequence Analysis in the Era of High-Throughput Sequencing. Cambridge University Press, Cambridge (2015)CrossRefGoogle Scholar
  19. 19.
    Pinter, R.Y.: Efficient string matching with don’t-care patterns. In: Apostolico, A., Galil, Z. (eds.) Combinatorial Algorithms on Words. NATO ASI Series, vol. F12, pp. 11–29. Springer, Heidelberg (1985).  https://doi.org/10.1007/978-3-642-82456-2_2CrossRefGoogle Scholar
  20. 20.
    Pissis, S.P.: MoTeX-II: structured motif extraction from large-scale datasets. BMC Bioinform. 15, 235 (2014)CrossRefGoogle Scholar
  21. 21.
    Régnier, M., Jacquet, P.: New results on the size of tries. IEEE Trans. Inf. Theory 35(1), 203–205 (1989)MathSciNetCrossRefGoogle Scholar

Copyright information

© Springer International Publishing AG, part of Springer Nature 2018

Authors and Affiliations

  • Mai Alzamel
    • 1
  • Panagiotis Charalampopoulos
    • 1
    Email author
  • Costas S. Iliopoulos
    • 1
  • Solon P. Pissis
    • 1
  1. 1.Department of InformaticsKing’s College LondonLondonUK

Personalised recommendations