Dynamic Trees with Almost-Optimal Access Cost

Authors Mordecai Golin, John Iacono, Stefan Langerman, J. Ian Munro, Yakov Nekrich

Thumbnail PDF


  • Filesize: 0.51 MB
  • 14 pages

Document Identifiers

Author Details

Mordecai Golin
  • Hong Kong University of Science and Technology
John Iacono
  • Université libre de Bruxelles and New York University
Stefan Langerman
  • Université libre de Bruxelles
J. Ian Munro
  • Cheriton School of Computer Science, University of Waterloo
Yakov Nekrich
  • Cheriton School of Computer Science, University of Waterloo

Cite AsGet BibTex

Mordecai Golin, John Iacono, Stefan Langerman, J. Ian Munro, and Yakov Nekrich. Dynamic Trees with Almost-Optimal Access Cost. In 26th Annual European Symposium on Algorithms (ESA 2018). Leibniz International Proceedings in Informatics (LIPIcs), Volume 112, pp. 38:1-38:14, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2018)


An optimal binary search tree for an access sequence on elements is a static tree that minimizes the total search cost. Constructing perfectly optimal binary search trees is expensive so the most efficient algorithms construct almost optimal search trees. There exists a long literature of constructing almost optimal search trees dynamically, i.e., when the access pattern is not known in advance. All of these trees, e.g., splay trees and treaps, provide a multiplicative approximation to the optimal search cost. In this paper we show how to maintain an almost optimal weighted binary search tree under access operations and insertions of new elements where the approximation is an additive constant. More technically, we maintain a tree in which the depth of the leaf holding an element e_i does not exceed min(log(W/w_i),log n)+O(1) where w_i is the number of times e_i was accessed and W is the total length of the access sequence. Our techniques can also be used to encode a sequence of m symbols with a dynamic alphabetic code in O(m) time so that the encoding length is bounded by m(H+O(1)), where H is the entropy of the sequence. This is the first efficient algorithm for adaptive alphabetic coding that runs in constant time per symbol.

Subject Classification

ACM Subject Classification
  • Theory of computation → Data structures design and analysis
  • Data Structures
  • Binary Search Trees
  • Adaptive Alphabetic Coding


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


  1. Georgy Adelson-Velsky and Evgenii Landis. An algorithm for the organization of information. Soviet Mathematics - Doklady, 3:1259-1262, 1962. Google Scholar
  2. Rudolf Ahlswede and Ingo Wegner. Search Problems. John Wiley and Sons, Chichester, 1987. Google Scholar
  3. Brian Allen. On the costs of optimal and near-optimal binary search trees. Acta Informatica, 18:255-263, 1982. Google Scholar
  4. Arne Andersson. Optimal bounds on the dictionary problem. In Proc. International Symposium on Optimal Algorithms, pages 106-114, 1989. Google Scholar
  5. Arne Andersson, Rolf Fagerberg, and Kim S. Larsen. Balanced binary search trees. In Dinesh P. Mehta and Sartaj Sahni, editors, Handbook of Data Structures and Applications. Chapman and Hall/CRC, 2004. Google Scholar
  6. Arne Andersson and Tony W. Lai. Comparison-efficient and write-optimal searching and sorting. In (Proc. 2nd International Symposium on Algorithms (ISA '91), pages 273-282, 1991. Google Scholar
  7. Rudolf Bayer. Symmetric binary b-trees: Data structure and maintenance algorithms. Acta Informatica, 1(4):290-306, Dec 1972. Google Scholar
  8. Michael A. Bender, Richard Cole, Erik D. Demaine, Martin Farach-Colton, and Jack Zito. Two simplified algorithms for maintaining order in a list. In Proc. 10th Annual European Symposium on Algorithms (ESA 2002), pages 152-164, 2002. Google Scholar
  9. Michael A. Bender, Jeremy T. Fineman, Seth Gilbert, Tsvi Kopelowitz, and Pablo Montes. File maintenance: When in doubt, change the layout! In Proc. 28th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2017), pages 1503-1522, 2017. Google Scholar
  10. Paul Dietz and Daniel Sleator. Two algorithms for maintaining order in a list. In Proceedings of the 19th Annual ACM Symposium on Theory of Computing (STOC 1987), pages 365-372. ACM, 1987. Google Scholar
  11. Rolf Fagerberg. Binary search trees: How low can you go? In Proc. 5th Scandinavian Workshop on Algorithm Theory (SWAT '96), pages 428-439, 1996. Google Scholar
  12. Travis Gagie. Dynamic shannon coding. In Proc. 12th Annual European Symposium on Algorithms (ESA 2004), pages 359-370, 2004. Google Scholar
  13. Adriano M. Garsia and Michelle L. Wachs. A New Algorithm for Minimum Cost Binary Trees. SIAM Journal on Computing, 6(4):622-642, 1977. Google Scholar
  14. E.N. Gilbert and E.F. Moore. Variable-length binary encodings. Bell System Technical Journal, 38(4):933-967, 1959. Google Scholar
  15. Mordecai Golin, John Iacono, Stefan Langerman, J. Ian Munro, and Yakov Nekrich. Dynamic trees with almost-optimal access cost. URL: http://arxiv.org/abs/1806.10498.
  16. Leonidas J. Guibas and Robert Sedgewick. A dichromatic framework for balanced trees. In 19th Annual Symposium on Foundations of Computer Science (FOCS 1978), pages 8-21, 1978. Google Scholar
  17. T. C. Hu, Lawrence L Larmore, and J David Morgenthaler. Optimal Integer Alphabetic Trees in Linear Time. In 13th Annual European Symposium on Algorithms (ESA'05), volume 3669, pages 226-237, 2005. Google Scholar
  18. T. C. Hu and A. C. Tucker. Optimal Computer Search Trees and Variable-Length Alphabetical Codes. SIAM Journal on Applied Mathematics, 21(4):514-532, 1971. Google Scholar
  19. Maria Klawe and Brendan Mumey. Upper and Lower Bounds on Constructing Alphabetic Binary Trees. SIAM Journal on Discrete Mathematics, 8(4):638-651, 1995. Google Scholar
  20. D. E. Knuth. Dynamic Huffman coding. Journal of Algorithms, 6:163-180, 1985. Google Scholar
  21. Donald E. Knuth. Optimum binary search trees. Acta informatica, 1(1):14-25, 1971. Google Scholar
  22. Hermann A. Maurer, Thomas Ottmann, and Hans-Werner Six. Implementing dictionaries using binary trees of very small height. Information Processing Letters, 5(1):11-14, 1976. Google Scholar
  23. Kurt Mehlhorn. A best possible bound for the weighted path length of binary search trees. SIAM Journal on Computing, 6(2):235-239, 1977. Google Scholar
  24. Raimund Seidel and Cecilia R. Aragon. Randomized search trees. Algorithmica, 16(4):464-497, 1996. Google Scholar
  25. Daniel Dominic Sleator and Robert Endre Tarjan. Self-adjusting binary search trees. Journal of the ACM (JACM), 32(3):652-686, 1985. Google Scholar
  26. J. S. Vitter. Design and analysis of dynamic Huffman codes. Journal of the ACM, 1987(4):825-845, 1987. Google Scholar
  27. Dan E. Willard. A density control algorithm for doing insertions and deletions in a sequentially ordered file in good worst-case time. Inf. Comput., 97(2):150-204, 1992. Google Scholar
  28. R.W. Yeung. Alphabetic codes revisited. IEEE Transactions on Information Theory, 37(3):564-572, may 1991. Google Scholar