Fast Approximation of Search Trees on Trees with Centroid Trees

Authors Benjamin Aram Berendsohn, Ishay Golinsky, Haim Kaplan , László Kozma

Thumbnail PDF


  • Filesize: 0.94 MB
  • 20 pages

Document Identifiers

Author Details

Benjamin Aram Berendsohn
  • Institut für Informatik, Freie Universität Berlin, Germany
Ishay Golinsky
  • Blavatnik School of Computer Science, Tel Aviv University, Israel
Haim Kaplan
  • Blavatnik School of Computer Science, Tel Aviv University, Israel
László Kozma
  • Institut für Informatik, Freie Universität Berlin, Germany

Cite AsGet BibTex

Benjamin Aram Berendsohn, Ishay Golinsky, Haim Kaplan, and László Kozma. Fast Approximation of Search Trees on Trees with Centroid Trees. In 50th International Colloquium on Automata, Languages, and Programming (ICALP 2023). Leibniz International Proceedings in Informatics (LIPIcs), Volume 261, pp. 19:1-19:20, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2023)


Search trees on trees (STTs) generalize the fundamental binary search tree (BST) data structure: in STTs the underlying search space is an arbitrary tree, whereas in BSTs it is a path. An optimal BST of size n can be computed for a given distribution of queries in 𝒪(n²) time [Knuth, Acta Inf. 1971] and centroid BSTs provide a nearly-optimal alternative, computable in 𝒪(n) time [Mehlhorn, SICOMP 1977]. By contrast, optimal STTs are not known to be computable in polynomial time, and the fastest constant-approximation algorithm runs in 𝒪(n³) time [Berendsohn, Kozma, SODA 2022]. Centroid trees can be defined for STTs analogously to BSTs, and they have been used in a wide range of algorithmic applications. In the unweighted case (i.e., for a uniform distribution of queries), the centroid tree can be computed in 𝒪(n) time [Brodal, Fagerberg, Pedersen, Östlin, ICALP 2001; Della Giustina, Prezza, Venturini, SPIRE 2019]. These algorithms, however, do not readily extend to the weighted case. Moreover, no approximation guarantees were previously known for centroid trees in either the unweighted or weighted cases. In this paper we revisit centroid trees in a general, weighted setting, and we settle both the algorithmic complexity of constructing them, and the quality of their approximation. For constructing a weighted centroid tree, we give an output-sensitive 𝒪(n log h) ⊆ 𝒪(n log n) time algorithm, where h is the height of the resulting centroid tree. If the weights are of polynomial complexity, the running time is 𝒪(n log log n). We show these bounds to be optimal, in a general decision tree model of computation. For approximation, we prove that the cost of a centroid tree is at most twice the optimum, and this guarantee is best possible, both in the weighted and unweighted cases. We also give tight, fine-grained bounds on the approximation-ratio for bounded-degree trees and on the approximation-ratio of more general α-centroid trees.

Subject Classification

ACM Subject Classification
  • Theory of computation → Data structures design and analysis
  • centroid tree
  • search trees on trees
  • approximation


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


  1. Stephen Alstrup, Jacob Holm, Kristian De Lichtenberg, and Mikkel Thorup. Maintaining information in fully dynamic trees with top trees. ACM Trans. Algorithms, 1(2):243-264, October 2005. URL:
  2. Bengt Aspvall and Pinar Heggernes. Finding minimum height elimination trees for interval graphs in polynomial time. BIT, 34:484-509, 1994. Google Scholar
  3. Yosi Ben-Asher, Eitan Farchi, and Ilan Newman. Optimal search in trees. SIAM J. Comput., 28(6):2090-2102, 1999. URL:
  4. Michael A. Bender, Martin Farach-Colton, and Bradley C. Kuszmaul. Cache-oblivious string b-trees. In ACM SIGMOD-SIGACT-SIGART, pages 233-242, 2006. Google Scholar
  5. Benjamin Aram Berendsohn. The diameter of caterpillar associahedra. In Artur Czumaj and Qin Xin, editors, 18th Scandinavian Symposium and Workshops on Algorithm Theory, SWAT 2022, June 27-29, 2022, Tórshavn, Faroe Islands, volume 227 of LIPIcs, pages 14:1-14:12. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2022. URL:
  6. Benjamin Aram Berendsohn, Ishay Golinsky, Haim Kaplan, and László Kozma. Fast approximation of search trees on trees with centroid trees, 2022. URL:
  7. Benjamin Aram Berendsohn and László Kozma. Splay trees on trees. In SODA, pages 1875-1900, 2022. Google Scholar
  8. Hans L. Bodlaender, Jitender S. Deogun, Klaus Jansen, Ton Kloks, Dieter Kratsch, Haiko Müller, and Zsolt Tuza. Rankings of graphs. SIAM Journal on Discrete Mathematics, 11(1):168-181, 1998. Google Scholar
  9. H.L. Bodlaender, J.R. Gilbert, H. Hafsteinsson, and T. Kloks. Approximating treewidth, pathwidth, frontsize, and shortest elimination tree. Journal of Algorithms, 18(2):238-255, 1995. URL:
  10. Prosenjit Bose, Jean Cardinal, John Iacono, Grigorios Koumoutsos, and Stefan Langerman. Competitive online search trees on trees. In SODA, pages 1878-1891, 2020. Google Scholar
  11. Gerth Stølting Brodal, Rolf Fagerberg, Christian N. S. Pedersen, and Anna Östlin. The complexity of constructing evolutionary trees using experiments. In ICALP, pages 140-151. Springer, 2001. Google Scholar
  12. Jean Cardinal, Stefan Langerman, and Pablo Pérez-Lantero. On the diameter of tree associahedra. Electron. J. Comb., 25(4):P4.18, 2018. URL:, URL:
  13. Jean Cardinal, Lionel Pournin, and Mario Valencia-Pabon. Bounds on the diameter of graph associahedra. In Proceedings of the XI Latin and American Algorithms, Graphs and Optimization Symposium (LAGOS), volume 195 of Procedia Computer Science, pages 239-247. Elsevier, 2021. Google Scholar
  14. Michael Carr and Satyan L. Devadoss. Coxeter complexes and graph-associahedra. Topology and its Applications, 153(12):2155-2168, 2006. Google Scholar
  15. Cesar Ceballos, Thibault Manneville, Vincent Pilaud, and Lionel Pournin. Diameters and geodesic properties of generalizations of the associahedron. In Proceedings of the 27th International Conference on Formal Power Series and Algebraic Combinatorics (FPSAC), pages 345-356, 2015. Google Scholar
  16. Panagiotis Charalampopoulos, Pawel Gawrychowski, Shay Mozes, and Oren Weimann. An almost optimal edit distance oracle. In Nikhil Bansal, Emanuela Merelli, and James Worrell, editors, 48th International Colloquium on Automata, Languages, and Programming, ICALP 2021, July 12-16, 2021, Glasgow, Scotland (Virtual Conference), volume 198 of LIPIcs, pages 48:1-48:20. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2021. URL:
  17. Ferdinando Cicalese, Tobias Jacobs, Eduardo Laber, and Marco Molinaro. On the complexity of searching in trees and partially ordered structures. Theor. Comput. Sci., 412(50):6879-6896, 2011. URL:
  18. Ferdinando Cicalese, Tobias Jacobs, Eduardo Laber, and Marco Molinaro. Improved approximation algorithms for the average-case tree searching problem. Algorithmica, 68(4):1045-1074, 2014. URL:
  19. Erik D. Demaine, Dion Harmon, John Iacono, and Mihai Pǎtraşcu. Dynamic optimality - almost. SIAM J. Comput., 37(1):240-251, 2007. URL:
  20. Jitender S Deogun, Ton Kloks, Dieter Kratsch, and Haiko Müller. On vertex ranking for permutation and other graphs. In STACS 1994, pages 747-758. Springer, 1994. Google Scholar
  21. Satyan L. Devadoss. A realization of graph associahedra. Discrete Mathematics, 309(1):271-276, 2009. Google Scholar
  22. Iain S Duff, Albert Maurice Erisman, and John Ker Reid. Direct methods for sparse matrices. Oxford University Press, 2017. Google Scholar
  23. Guy Even and Shakhar Smorodinsky. Hitting sets online and unique-max coloring. Discret. Appl. Math., 178:71-82, 2014. URL:
  24. Paolo Ferragina. On the weak prefix-search problem. Theor. Comput. Sci., 483:75-84, 2013. URL:
  25. Paolo Ferragina and Rossano Venturini. Compressed cache-oblivious string b-tree. ACM Trans. Algorithms, 12(4):52:1-52:17, 2016. URL:
  26. Greg N. Frederickson and Donald B Johnson. Finding kth paths and p-centers by generating and searching good data structures. Journal of Algorithms, 4(1):61-80, 1983. Google Scholar
  27. Travis Gagie, Danny Hermelin, Gad M Landau, and Oren Weimann. Binary jumbled pattern matching on trees and tree-like structures. Algorithmica, 73(3):571-588, 2015. Google Scholar
  28. Davide Della Giustina, Nicola Prezza, and Rossano Venturini. A new linear-time algorithm for centroid decomposition. In Proceedings of the 26th International Symposium on String Processing and Information Retrieval (SPIRE), volume 11811 of Lecture Notes in Computer Science, pages 274-282. Springer, 2019. Google Scholar
  29. Michael T. Goodrich and Roberto Tamassia. Dynamic trees and dynamic point location. SIAM J. Comput., 28(2):612-636, 1998. URL:
  30. Leonidas J. Guibas, John Hershberger, Daniel Leven, Micha Sharir, and Robert Endre Tarjan. Linear-time algorithms for visibility and shortest path problems inside triangulated simple polygons. Algorithmica, 2:209-233, 1987. URL:
  31. Brent Heeringa, Marius Catalin Iordan, and Louis Theran. Searching in dynamic tree-like partial orders. In WADS 2011, volume 6844 of Lecture Notes in Computer Science, pages 512-523. Springer, 2011. URL:
  32. D.S. Hirschberg, L.L. Larmore, and M. Molodowitch. Subtree weight ratios for optimal binary search trees. Technical Report TR 86-02, ICS Department, University of California, Irvine, 1986. Google Scholar
  33. Ananth V. Iyer, H. Donald Ratliff, and Gopalakrishnan Vijayan. Optimal node ranking of trees. Inf. Process. Lett., 28(5):225-229, 1988. URL:
  34. Camille Jordan. Sur les assemblages de lignes. Journal für die reine und angewandte Mathematik, 70:185-190, 1869. Google Scholar
  35. Meir Katchalski, William McCuaig, and Suzanne Seager. Ordered colourings. Discrete Mathematics, 142(1-3):141-154, 1995. Google Scholar
  36. Donald E. Knuth. Optimum binary search trees. Acta Informatica, 1(1):14-25, 1971. URL:
  37. Tomasz Kociumaka, Jakub Pachocki, Jakub Radoszewski, Wojciech Rytter, and Tomasz Waleń. Efficient counting of square substrings in a tree. Theoretical Computer Science, 544:60-73, 2014. Google Scholar
  38. Eduardo Laber and Marco Molinaro. An approximation algorithm for binary searching in trees. Algorithmica, 59(4):601-620, 2011. URL:
  39. Eduardo Laber and Loana Nogueira. Fast searching in trees. Electronic Notes in Discrete Mathematics, 7:90-93, 2001. URL:
  40. Lawrence L. Larmore. A subquadratic algorithm for constructing approximately optimal binary search trees. J. Algorithms, 8(4):579-591, 1987. URL:
  41. Charles E. Leiserson. Area-efficient graph layouts (for VLSI). In STOC 1980, pages 270-281. IEEE Computer Society, 1980. URL:
  42. Nathan Linial and Michael E. Saks. Every poset has a central element. J. Comb. Theory, Ser. A, 40(2):195-210, 1985. URL:
  43. Joseph W.H. Liu. The role of elimination trees in sparse factorization. SIAM journal on matrix analysis and applications, 11(1):134-172, 1990. Google Scholar
  44. Kurt Mehlhorn. Nearly optimal binary search trees. Acta Informatica, 5(4):287-295, 1975. Google Scholar
  45. Kurt Mehlhorn. A best possible bound for the weighted path length of binary search trees. SIAM Journal on Computing, pages 235-239, 1977. Google Scholar
  46. Shay Mozes, Krzysztof Onak, and Oren Weimann. Finding an optimal tree searching strategy in linear time. In SODA 2008, pages 1096-1105. SIAM, 2008. URL:
  47. Jaroslav Nesetril and Patrice Ossona de Mendez. Sparsity - Graphs, Structures, and Algorithms, volume 28 of Algorithms and combinatorics. Springer, 2012. URL:
  48. Krzysztof Onak and Pawel Parys. Generalization of binary search: Searching in trees and forest-like partial orders. In FOCS 2006, pages 379-388, 2006. URL:
  49. Alex Pothen, Horst D. Simon, and Kang-Pu Liou. Partitioning sparse matrices with eigenvectors of graphs. SIAM journal on matrix analysis and applications, 11(3):430-452, 1990. Google Scholar
  50. Alejandro A. Schäffer. Optimal node ranking of trees in linear time. Information Processing Letters, 33(2):91-96, 1989. Google Scholar
  51. Daniel Dominic Sleator and Robert Endre Tarjan. Self-adjusting binary search trees. J. ACM, 32(3):652-686, July 1985. URL:
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