Abstract
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).
Preview
Unable to display preview. Download preview PDF.
References
A. AHO, J. HOPCROFT, J. ULLMAN ”The Design and Analysis of Computer Algorithms”, Addison-Wesley, Reading, MA, 1974
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)
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)
D. HAREL and R.E. TARJAN ”Fast Algorithms for finding Nearest Common Ancestors”, SIAM Journal of Computing, Vol. 13, pp. 338–355 (1984)
J.v.LEEUWEN ”Finding Lowest Common Ancestors in less than Logarithmic Time”, unpublished report (1976)
D. MAIER ”An Efficient Method for storing Ancestor Information in Trees”, SIAM Journal of Computing, Vol. 8, No 4, pp. 599–618 (1979)
D.SLEATOR and R.E.TARJAN ”A Data Structure for Dynamic Trees”, Journal of Computer and System Science 26, pp. 362–391 (1983)
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)
R.E. TARJAN and J. v.LEEUWEN ”Worst-Case Analysis of Set Union Algorithms”, Journal of ACM, Vol. 31, pp. 245–281 (1984)
A.K. TSAKALIDIS ”Maintaining Order in a Generalized Linked List”, Acta Informatica 21, pp. 101–112 (1984)
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1987 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Tsakalidis, A.K. (1987). The nearest common ancestor in a dynamic tree. In: Ottmann, T. (eds) Automata, Languages and Programming. ICALP 1987. Lecture Notes in Computer Science, vol 267. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-18088-5_42
Download citation
DOI: https://doi.org/10.1007/3-540-18088-5_42
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-18088-3
Online ISBN: 978-3-540-47747-1
eBook Packages: Springer Book Archive