Springer Nature is making SARS-CoV-2 and COVID-19 research free. View research | View latest news | Sign up for updates

# Optimal Encodings for Range Majority Queries

• 186 Accesses

• 2 Citations

## Abstract

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.

This is a preview of subscription content, log in to check access.

## Notes

1. 1.

Or an equivalent array where each element is replaced by an identifier in $$[1,n]$$.

2. 2.

Bounding $$\lg (k!)$$ with integrals one obtains $$k \lg (k/e) + 1 \le \lg (k!) \le (k+1)\lg ((k+1)/e)+1$$.

3. 3.

We could also afford to store them in plain form, in $$O((1/\tau )(\lceil \log (1/\tau )\rceil +\log \log n))$$ bits.

## References

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)

2. 2.

Berkman, O., Vishkin, U.: Recursive star-tree parallel data structure. SIAM J. Comput. 22(2), 221–242 (1993)

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)

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)

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)

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)

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)

8. 8.

Clark, D.: Compact PAT trees. Ph.D. thesis, University of Waterloo, Canada (1996)

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)

10. 10.

Elias, P.: Efficient storage and retrieval by content and address of static files. J. ACM 21, 246–260 (1974)

11. 11.

Fano, R.: On the number of bits required to implement an associative memory. Memo 61, Computer Structures Group, Project MAC, MA (1971)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

## Acknowledgments

We thank the reviewers for their valuable comments.

## Author information

Correspondence to Gonzalo Navarro.

An early version of this article appeared in Proc. CPM 2014 [19].

Gonzalo Navarro: Partially funded by Millennium Nucleus Information and Coordination in Networks ICM/FIC P10-024F, Chile.

## Rights and permissions

Reprints and Permissions

Navarro, G., Thankachan, S.V. Optimal Encodings for Range Majority Queries. Algorithmica 74, 1082–1098 (2016). https://doi.org/10.1007/s00453-015-9987-8