Better Space Bounds for Parameterized Range Majority and Minority

  • Djamal Belazzougui
  • Travis Gagie
  • Gonzalo Navarro
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8037)


Karpinski and Nekrich (2008) introduced the problem of parameterized range majority, which asks to preprocess a string of length n such that, given the endpoints of a range, one can quickly find all the distinct elements whose relative frequencies in that range are more than a threshold τ. Subsequent authors have reduced their time and space bounds such that, when τ is given at preprocessing time, we need either \(\mathcal{O}\!\left( {n \lg (1 / \tau) } \right)\) space and optimal \(\mathcal{O}\!\left( {1 / \tau} \right)\) query time or linear space and \(\mathcal{O}\!\left( {(1 / \tau) \lg \lg \sigma} \right)\) query time, where σ is the alphabet size. In this paper we give the first linear-space solution with optimal \(\mathcal{O}\!\left( {1 / \tau} \right)\) query time. For the case when τ is given at query time, we significantly improve previous bounds, achieving either \(\mathcal{O}\!\left( {n \lg \lg \sigma} \right)\) space and optimal \(\mathcal{O}\!\left( {1 / \tau} \right)\) query time or compressed space and \(\mathcal{O}\!\left( {(1 / \tau) \lg \frac{\lg (1 / \tau)}{\lg \lg n}} \right)\) query time. Along the way, we consider the complementary problem of parameterized range minority that was recently introduced by Chan et al. (2012), who achieved linear space and \(\mathcal{O}\!\left( {1 / \tau} \right)\) query time even for variable τ. We improve their solution to use either nearly optimally compressed space with no slowdown, or optimally compressed space with nearly no slowdown. Some of our intermediate results, such as density-sensitive query time for one-dimensional range counting, may be of independent interest.


Distinct Element Binary String Query Time Range Mode Full Version 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Barbay, J., Claude, F., Gagie, T., Navarro, G., Nekrich, Y.: Efficient fully-compressed sequence representations. Algorithmica (to appear)Google Scholar
  2. 2.
    Belazzougui, D., Navarro, G.: Alphabet-independent compressed text indexing. ACM Transactions on Algorithms (to appear)Google Scholar
  3. 3.
    Belazzougui, D., Navarro, G.: Alphabet-independent compressed text indexing. In: Demetrescu, C., Halldórsson, M.M. (eds.) ESA 2011. LNCS, vol. 6942, pp. 748–759. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  4. 4.
    Belazzougui, D., Navarro, G.: New lower and upper bounds for representing sequences. In: Epstein, L., Ferragina, P. (eds.) ESA 2012. LNCS, vol. 7501, pp. 181–192. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  5. 5.
    Bose, P., Kranakis, E., Morin, P., Tang, Y.: Approximate range mode and range median queries. In: Diekert, V., Durand, B. (eds.) STACS 2005. LNCS, vol. 3404, pp. 377–388. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  6. 6.
    Chan, T.M., Durocher, S., Larsen, K.G., Morrison, J., Wilkinson, B.T.: Linear-space data structures for range mode query in arrays. In: Proceedings of the 29th Symposium on Theoretical Aspects of Computer Science (STACS), pp. 290–301 (2012)Google Scholar
  7. 7.
    Chan, T.M., Durocher, S., Skala, M., Wilkinson, B.T.: Linear-space data structures for range minority query in arrays. In: Fomin, F.V., Kaski, P. (eds.) SWAT 2012. LNCS, vol. 7357, pp. 295–306. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  8. 8.
    Cormode, G., Muthukrishnan, S.: Data stream methods. Lecture 3 of Rutger’s 198:671 Seminar on Processing Massive Data Sets (2003),
  9. 9.
    Demaine, E.D., López-Ortiz, A., Munro, J.I.: Frequency estimation of internet packet streams with limited space. In: Möhring, R.H., Raman, R. (eds.) ESA 2002. LNCS, vol. 2461, pp. 348–360. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  10. 10.
    Durocher, S., He, M., Munro, J.I., Nicholson, P.K., Skala, M.: Range majority in constant time and linear space. Information and Computation 222, 169–179 (2013)MathSciNetMATHCrossRefGoogle Scholar
  11. 11.
    Elmasry, A., He, M., Munro, J.I., Nicholson, P.K.: Dynamic range majority data structures. In: Asano, T., Nakano, S.-I., Okamoto, Y., Watanabe, O. (eds.) ISAAC 2011. LNCS, vol. 7074, pp. 150–159. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  12. 12.
    Ferragina, P., Manzini, G., Mäkinen, V., Navarro, G.: Compressed representations of sequences and full-text indexes. ACM Transactions on Algorithms 3(2) (2007)Google Scholar
  13. 13.
    Fischer, J.: Optimal succinctness for range minimum queries. In: López-Ortiz, A. (ed.) LATIN 2010. LNCS, vol. 6034, pp. 158–169. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  14. 14.
    Gagie, T., He, M., Munro, J.I., Nicholson, P.K.: Finding frequent elements in compressed 2D arrays and strings. In: Grossi, R., Sebastiani, F., Silvestri, F. (eds.) SPIRE 2011. LNCS, vol. 7024, pp. 295–300. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  15. 15.
    Greve, M., Jørgensen, A.G., Larsen, K.D., Truelsen, J.: Cell probe lower bounds and approximations for range mode. In: Abramsky, S., Gavoille, C., Kirchner, C., Meyer auf der Heide, F., Spirakis, P.G. (eds.) ICALP 2010. LNCS, vol. 6198, pp. 605–616. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  16. 16.
    Karp, R.M., Shenker, S., Papadimitriou, C.H.: A simple algorithm for finding frequent elements in streams and bags. ACM Transactions on Database Systems 28(1), 51–55 (2003)CrossRefGoogle Scholar
  17. 17.
    Karpinski, M., Nekrich, Y.: Searching for frequent colors in rectangles. In: Proceedings of the 20th Canadian Conference on Computational Geometry (CCCG), pp. 11–14 (2008)Google Scholar
  18. 18.
    Krizanc, D., Morin, P., Smid, M.H.M.: Range mode and range median queries on lists and trees. Nordic Journal of Computing 12(1), 1–17 (2005)MathSciNetMATHGoogle Scholar
  19. 19.
    Lai, Y.K., Poon, C.K., Shi, B.: Approximate colored range and point enclosure queries. Journal of Discrete Algorithms 6(3), 420–432 (2008)MathSciNetMATHCrossRefGoogle Scholar
  20. 20.
    Misra, J., Gries, D.: Finding repeated elements. Science of Computer Programming 2(2), 143–152 (1982)MathSciNetMATHCrossRefGoogle Scholar
  21. 21.
    Muthukrishnan, S.: Efficient algorithms for document retrieval problems. In: Proceedings of the 13th Symposium on Discrete Algorithms (SODA), pp. 657–666 (2002)Google Scholar
  22. 22.
    Petersen, H.: Improved bounds for range mode and range median queries. In: Geffert, V., Karhumäki, J., Bertoni, A., Preneel, B., Návrat, P., Bieliková, M. (eds.) SOFSEM 2008. LNCS, vol. 4910, pp. 418–423. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  23. 23.
    Petersen, H., Grabowski, S.: Range mode and range median queries in constant time and sub-quadratic space. Information Processing Letter 109(4), 225–228 (2009)MathSciNetMATHCrossRefGoogle Scholar
  24. 24.
    Pǎtraşcu, M.: Succincter. In: Proceedings of the 49th Symposium on Foundations of Computer Science (FOCS), pp. 305–313 (2008)Google Scholar
  25. 25.
    Sadakane, K.: Succinct data structures for flexible text retrieval systems. Journal of Discrete Algorithms 5(1), 12–22 (2007)MathSciNetMATHCrossRefGoogle Scholar
  26. 26.
    Wei, Z., Yi, K.: Beyond simple aggregates: indexing for summary queries. In: Proceedings of the 30th Symposium on Principles of Database Systems (PODS), pp. 117–128 (2011)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  • Djamal Belazzougui
    • 1
  • Travis Gagie
    • 1
    • 2
  • Gonzalo Navarro
    • 3
  1. 1.Department of Computer ScienceUniversity of HelsinkiFinland
  2. 2.Helsinki Institute for Information TechnologyFinland
  3. 3.Department of Computer ScienceUniversity of ChileChile

Personalised recommendations