Practical Implementation of Encoding Range Top-2 Queries

Authors Seungbum Jo, Wooyoung Park, Srinivasa Rao Satti

Thumbnail PDF


  • Filesize: 1 MB
  • 13 pages

Document Identifiers

Author Details

Seungbum Jo
  • Chungbuk National University, Cheongju, South Korea
Wooyoung Park
  • Seoul National University, South Korea
Srinivasa Rao Satti
  • Norwegian University of Science and Technology, Trondheim, Norway

Cite AsGet BibTex

Seungbum Jo, Wooyoung Park, and Srinivasa Rao Satti. Practical Implementation of Encoding Range Top-2 Queries. In 19th International Symposium on Experimental Algorithms (SEA 2021). Leibniz International Proceedings in Informatics (LIPIcs), Volume 190, pp. 10:1-10:13, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2021)


We design a practical variant of an encoding for range Top-2 queries (RT2Q), and evaluate its performance. Given an array A[1,n] of n elements from a total order, the range Top-2 encoding problem is to construct a data structure that can answer RT2Q queries, which return the positions of the first and the second largest elements within a given query range of A, without accessing the array A at query time. Davoodi et al. [Phil. Trans. Royal Soc. A, 2016] proposed a (3.272n + o(n))-bit encoding, which answers RT2Q queries in O(1) time, while Gawrychowski and Nicholson [ICALP, 2015] gave an optimal (2.755n + (n))-bit encoding which doesn't support efficient queries. In this paper, we propose the first practical implementation of the encoding data structure for answering RT2Q. Our implementation is based on an alternative representation of Davoodi et al.’s data structure. The experimental results show that our implementation is efficient in practice, and gives improved time-space trade-offs compared to the indexing data structures (which keep the original array A as part of the data structure) for range maximum queries.

Subject Classification

ACM Subject Classification
  • Theory of computation → Data structures design and analysis
  • Range top-2 query
  • Range minimum query
  • Cartesian tree
  • Succinct encoding


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Diego Arroyuelo, Rodrigo Cánovas, Gonzalo Navarro, and Kunihiko Sadakane. Succinct trees in practice. In Proceedings of ALENEX 2010, pages 84-97, 2010. Google Scholar
  2. Niklas Baumstark, Simon Gog, Tobias Heuer, and Julian Labeit. Practical range minimum queries revisited. In SEA 2017, pages 12:1-12:16, 2017. Google Scholar
  3. David Benoit, Erik D. Demaine, J. Ian Munro, Rajeev Raman, Venkatesh Raman, and S. Srinivasa Rao. Representing trees of higher degree. Algorithmica, 43(4):275-292, 2005. Google Scholar
  4. Pooya Davoodi, Gonzalo Navarro, Rajeev Raman, and S. Srinivasa Rao. Encoding range minima and range top-2 queries. Philosophical Transactions of the Royal Society A, 372(2016):20130131, 2014. Google Scholar
  5. Pooya Davoodi, Rajeev Raman, and Srinivasa Rao Satti. On succinct representations of binary trees. Math. Comput. Sci., 11(2):177-189, 2017. Google Scholar
  6. Luc Devroye. On random cartesian trees. Random Struct. Algorithms, 5(2):305-328, 1994. Google Scholar
  7. A. Farzan and J. I. Munro. A uniform paradigm to succinctly encode various families of trees. Algorithmica, 68(1):16-40, January 2014. Google Scholar
  8. Héctor Ferrada and Gonzalo Navarro. Improved range minimum queries. J. Discrete Algorithms, 43:72-80, 2017. Google Scholar
  9. Johannes Fischer and Volker Heun. Space-efficient preprocessing schemes for range minimum queries on static arrays. SIAM J. Comput., 40(2):465-492, 2011. Google Scholar
  10. Harold N. Gabow, Jon Louis Bentley, and Robert Endre Tarjan. Scaling and related techniques for geometry problems. In Proceedings of STOC 1984, pages 135-143, 1984. Google Scholar
  11. Pawel Gawrychowski and Patrick K. Nicholson. Optimal encodings for range top-k, selection, and min-max. In ICALP 2015, Proceedings, Part I, pages 593-604, 2015. Google Scholar
  12. Simon Gog, Timo Beller, Alistair Moffat, and Matthias Petri. From theory to practice: Plug and play with succinct data structures. In 13th International Symposium on Experimental Algorithms, (SEA 2014), pages 326-337, 2014. URL:
  13. Guy Jacobson. Space-efficient static trees and graphs. In FOCS 1989, pages 549-554, 1989. Google Scholar
  14. Jesper Jansson, Kunihiko Sadakane, and Wing-Kin Sung. Ultra-succinct representation of ordered trees with applications. J. Comput. Syst. Sci., 78(2):619-631, 2012. Google Scholar
  15. J. Ian Munro, Venkatesh Raman, and S. Srinivasa Rao. Space efficient suffix trees. J. Algorithms, 39(2):205-222, 2001. Google Scholar
  16. Gonzalo Navarro and Kunihiko Sadakane. Fully functional static and dynamic succinct trees. ACM Trans. Algorithms, 10(3):16:1-16:39, 2014. Google Scholar
  17. Rajeev Raman. Encoding data structures. In WALCOM 2015, pages 1-7, 2015. Google Scholar
  18. Rajeev Raman, Venkatesh Raman, and Srinivasa Rao Satti. Succinct indexable dictionaries with applications to encoding k-ary trees, prefix sums and multisets. ACM Trans. Algorithms, 3(4):43, 2007. Google Scholar
  19. Kunihiko Sadakane. Compressed suffix trees with full functionality. Theory Comput. Syst., 41(4):589-607, 2007. Google Scholar
  20. Jean Vuillemin. A unifying look at data structures. Commun. ACM, 23(4):229-239, 1980. Google Scholar
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail