, Volume 74, Issue 3, pp 1082–1098 | Cite as

Optimal Encodings for Range Majority Queries

  • Gonzalo NavarroEmail author
  • Sharma V. Thankachan


We study the problem of designing a data structure that reports the positions of the distinct \(\tau \)-majorities within any range of an array \(A[1,n]\), without storing \(A\). A \(\tau \)-majority in a range \(A[i,j]\), for \(0<\tau < 1\), is an element that occurs more than \(\tau (j-i+1)\) times in \(A[i,j]\). We show that \(\Omega (n\lceil \log (1/\tau )\rceil )\) bits are necessary for any data structure just able to count the number of distinct \(\tau \)-majorities in any range. Then, we design a structure using \(O(n\lceil \log (1/\tau )\rceil )\) bits that returns one position of each \(\tau \)-majority of \(A[i,j]\) in \(O((1/\tau )\log \log _w(1/\tau )\log n)\) time, on a RAM machine with word size \(w\) (it can output any further position where each \(\tau \)-majority occurs in \(O(1)\) additional time). Finally, we show how to remove a \(\log n\) factor from the time by adding \(O(n\log \log n)\) bits of space to the structure.


Range majority queries Encoding data structures  Succinct data structures 



We thank the reviewers for their valuable comments.


  1. 1.
    Belazzougui, D., Gagie, T., Navarro, G.: Better space bounds for parameterized range majority and minority. In: Proc. 11th Annual Workshop on Algorithms and Data Structures (WADS), pp. 121–132 (2013)Google Scholar
  2. 2.
    Berkman, O., Vishkin, U.: Recursive star-tree parallel data structure. SIAM J. Comput. 22(2), 221–242 (1993)CrossRefMathSciNetzbMATHGoogle Scholar
  3. 3.
    Bose, P., Kranakis, E., Morin, P., Tang, Y.: Approximate range mode and range median queries. In: Proc. 22nd International Symposium on Theoretical Aspects of Computer Science (STACS), pp. 377–388 (2005)Google Scholar
  4. 4.
    Brodal, G., Fagerberg, R., Greve, M., López-Ortiz, A.: Online sorted range reporting. In: Proc. 20th Annual International Symposium on Algorithms and Computation (ISAAC), pp. 173–182 (2009)Google Scholar
  5. 5.
    Chan, T., Durocher, S., Larsen, K., Morrison, J., Wilkinson, B.: Linear-space data structures for range mode query in arrays. In: Proc. 29th International Symposium on Theoretical Aspects of Computer Science (STACS), pp. 290–301 (2012)Google Scholar
  6. 6.
    Chan, T., Durocher, S., Skala, M., Wilkinson, B.: Linear-space data structures for range minority query in arrays. In: Proc. 13th Scandinavian Symposium on Algorithmic Theory (SWAT), pp. 295–306 (2012)Google Scholar
  7. 7.
    Chan, T., Wilkinson, B.: Adaptive and approximate orthogonal range counting. In: Proc. 24th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pp. 241–251 (2013)Google Scholar
  8. 8.
    Clark, D.: Compact PAT trees. Ph.D. thesis, University of Waterloo, Canada (1996)Google Scholar
  9. 9.
    Durocher, S., He, M., Munro, I., Nicholson, P., Skala, M.: Range majority in constant time and linear space. Inform. Comput. 222, 169–179 (2013)CrossRefMathSciNetzbMATHGoogle Scholar
  10. 10.
    Elias, P.: Efficient storage and retrieval by content and address of static files. J. ACM 21, 246–260 (1974)CrossRefMathSciNetzbMATHGoogle Scholar
  11. 11.
    Fano, R.: On the number of bits required to implement an associative memory. Memo 61, Computer Structures Group, Project MAC, MA (1971)Google Scholar
  12. 12.
    Fischer, J., Heun, V.: Space-efficient preprocessing schemes for range minimum queries on static arrays. SIAM J. Comput. 40(2), 465–492 (2011)CrossRefMathSciNetzbMATHGoogle Scholar
  13. 13.
    Gagie, T., He, M., Munro, I., Nicholson, P.: Finding frequent elements in compressed 2d arrays and strings. In: Proc. 18th International Symposium on String Processing and Information Retrieval (SPIRE), pp. 295–300 (2011)Google Scholar
  14. 14.
    Greve, M., Jørgensen, A., Larsen, K.D., Truelsen, J.: Cell probe lower bounds and approximations for range mode. In: Proc. 37th International Colloquium on Automata, Languages and Programming (ICALP), pp. 605–616 (2010)Google Scholar
  15. 15.
    Grossi, R., Iacono, J., Navarro, G., Raman, R., Satti, S.R.: Encodings for range selection and top-k queries. In: Proc. 21st Annual European Symposium on Algorithms (ESA), pp. 553–564 (2013)Google Scholar
  16. 16.
    Karpinski, M., Nekrich, Y.: Searching for frequent colors in rectangles. In: Proc. 20th Canadian Conference on Computational Geometry (CCCG), pp. 11–14 (2008)Google Scholar
  17. 17.
    Karpinski, M., Nekrich, Y.: Top-k color queries for document retrieval. In: Proc. 22nd Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pp. 401–411 (2011)Google Scholar
  18. 18.
    Navarro, G., Raman, R., Rao, S.S.: Asymptotically optimal encodings for range selection. In: Proc. 34th Annual Conference on Foundations of Software Technology and Theoretical Computer Science (FSTTCS), pp. 291–302 (2014)Google Scholar
  19. 19.
    Navarro, G., Thankachan, S.: Encodings for range majority queries. In: Kulikov, A.S., Kuznetsov, S.O., Pevzner, P.A. (eds.) Proc. 25th Annual Symposium on Combinatorial Pattern Matching CPM. LNCS 8486, pp. 262–272, (2014)Google Scholar
  20. 20.
    Okanohara, D., Sadakane, K.: Practical entropy-compressed rank/select dictionary. In: Proc. 9th Workshop on Algorithm Engineering and Experiments (ALENEX), pp. 60–70 (2007)Google Scholar
  21. 21.
    Petersen, H., Grabowski, S.: Range mode and range median queries in constant time and sub-quadratic space. Inform. Process. Lett. 109(4), 225–228 (2009)CrossRefMathSciNetzbMATHGoogle Scholar
  22. 22.
    Pătraşcu, M., Thorup, M.: Time-space trade-offs for predecessor search. CoRR (2008). arXiv:cs/0603043v1
  23. 23.
    Pǎtraşcu, M.: Succincter. In: Proc. 49th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pp. 305–313 (2008)Google Scholar
  24. 24.
    Raman, R., Raman, V., Rao, S.S.: Succinct indexable dictionaries with applications to encoding k-ary trees, prefix sums and multisets. ACM Trans. Algorithms 3(4) Article 43 (2007)Google Scholar
  25. 25.
    Ružić, M.: Constructing efficient dictionaries in close to sorting time. In: Aceto, L., Damgård, I., Ann Goldberg, L., Halldórsson, M.M., Ingólfsdóttir, A., Walukiewicz, I. (eds.) Proc. 35th International Colloquium on Automata, Languages and Programming ICALP. LNCS 5125, pp. 84–95 (part I) (2008)Google Scholar
  26. 26.
    Skala, M.: Array range queries. In: Brodnik, A., López-Ortiz, A., Raman, V., Viola A. (eds.) Space-Efficient Data Structures, Streams, and Algorithms. LNCS, pp. 333–350. Springer (2013)Google Scholar

Copyright information

© Springer Science+Business Media New York 2015

Authors and Affiliations

  1. 1.Department of Computer ScienceUniversity of ChileSantiagoChile
  2. 2.Georgia Institute of TechnologyAtlantaUSA

Personalised recommendations