Summary
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.
Similar content being viewed by others
References
Aho, A., Hopcroft, J., Ullman, J.: The Design and Analysis of Computer Algorithms. Reading, MA: Addison-Wesley, 1974
Aho, A., Hopcroft, J., Ullman, J.: On finding Lowest Common Ancestors in Trees. SIAM J. Comput. Vol 1, 115–132 (1976)
Harel, D.: A Linear Time Algorithm for the Lowest Common Ancestors problem. Proc. 21st IEEE Symposium on Foundations of Computer Science, pp. 308–319 (1980)
Harel, D., Tarjan, R.E.: Fast Algorithms for finding Nearest Common Ancestors. SIAM J. Comput. 13, 338–355 (1984)
Reference deleted
Maier, D.: An Efficient Method for storing Ancestor Information in Trees. SIAM J. Comput. 8, 599–618 (1979)
Schieber, B., Viskin, U.: On Finding Lowest Common Ancestors: Simplification and Parallelization. Technical Report 63/87, NY University, New York, (1987)
Sleator, D., Tarjan, R.E.: A Data Strucutre for Dynamic Trees, J. Comput. System Sci. 26, 362–391 (1983)
Tarjan, R.E.: A Class of Algorithms which require non-linear time to maintain Disjoint Sets. J. Comput. System Sci. 18, 110–127 (1979)
Tarjan, R.E., v. Leeuwen, J.: Worst-Case Analysis of Set Union Algorithms. Journal of ACM, 31, 245–281 (1984)
Tsakalidis, A.K.: Maintaining Order in a Generalized Linked List. Acta Informatica 21, 101–112 (1984)
Author information
Authors and Affiliations
Rights and permissions
About this article
Cite this article
Tsakalidis, A.K. The nearest common ancestor in a dynamic tree. Acta Informatica 25, 37–54 (1988). https://doi.org/10.1007/BF00268844
Received:
Issue Date:
DOI: https://doi.org/10.1007/BF00268844