The nearest common ancestor in a dynamic tree

  • Athanasios K. Tsakalidis
Algorithms And Complexity
Part of the Lecture Notes in Computer Science book series (LNCS, volume 267)


We consider the problem of determining the nearest common ancestor of two given nodes x and y (denoted by nca(x,y)) in a dynamic arbitrary tree T. We present an implementation of T by a pointer machine which needs linear space, performs m arbitrary insertions and deletions in the initially empty tree T in time O(m) and a query about nca(x,y) can be answered on-line in time O(log(min{depth(x), depth(y)})+α(k,k)), where the second factor is amortized over k queries, α is a functional inverse of Ackermann's function and depth(x) the distance from node x to the root of T.

We also consider the static version of the problem and give an optimal pointer machine algorithm which needs O(n) preprocessing time, space O(n) and answers a query on-line in time O(log log n).


Common Ancestor Query Time Search Path Dynamic Tree Main Representative 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [1]
    A. AHO, J. HOPCROFT, J. ULLMAN ”The Design and Analysis of Computer Algorithms”, Addison-Wesley, Reading, MA, 1974Google Scholar
  2. [2]
    A. AHO, J. HOPCROFT, J. ULLMAN ”On finding Lowest Common Ancestors in Trees”, SIAM Journal of Computing, Vol. 1, No 1, pp. 115–132 (1976)Google Scholar
  3. [3]
    D.HAREL ”A Linear Time Algorithm for the Lowest Common Ancestors problem”, Proc. 21st IEEE Symposium on Foundations of Computer Science, pp.308–319 (1980)Google Scholar
  4. [4]
    D. HAREL and R.E. TARJAN ”Fast Algorithms for finding Nearest Common Ancestors”, SIAM Journal of Computing, Vol. 13, pp. 338–355 (1984)Google Scholar
  5. [5]
    J.v.LEEUWEN ”Finding Lowest Common Ancestors in less than Logarithmic Time”, unpublished report (1976)Google Scholar
  6. [6]
    D. MAIER ”An Efficient Method for storing Ancestor Information in Trees”, SIAM Journal of Computing, Vol. 8, No 4, pp. 599–618 (1979)Google Scholar
  7. [7]
    D.SLEATOR and R.E.TARJAN ”A Data Structure for Dynamic Trees”, Journal of Computer and System Science 26, pp. 362–391 (1983)Google Scholar
  8. [8]
    R.E. TARJAN ”A Class of Algorithms which require non-linear time to maintain Disjoint Sets”, J. Comput. System Sci., 18, pp. 110–127 (1979)CrossRefGoogle Scholar
  9. [9]
    R.E. TARJAN and J. v.LEEUWEN ”Worst-Case Analysis of Set Union Algorithms”, Journal of ACM, Vol. 31, pp. 245–281 (1984)CrossRefGoogle Scholar
  10. [10]
    A.K. TSAKALIDIS ”Maintaining Order in a Generalized Linked List”, Acta Informatica 21, pp. 101–112 (1984)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1987

Authors and Affiliations

  • Athanasios K. Tsakalidis
    • 1
    • 2
  1. 1.Informatik Universität des SaarlandesSaarbrückenGermany
  2. 2.Computer Technology InstitutePatrasGreece

Personalised recommendations