Nearest common ancestors
- 10 August 2002
- proceedings article
- Published by Association for Computing Machinery (ACM)
- p. 258-264
- https://doi.org/10.1145/564870.564914
Abstract
Several papers describe linear time algorithms to preprocess a tree, such that one can answer subsequent nearest common ancestor queries in constant time. Here, we survey these algorithms and related results. A common idea used by all the algorithms for the problem is that a solution for complete binary trees is straightforward. Furthermore, for complete binary trees we can easily solve the problem in a distributed way by labeling the nodes of the tree such that from the labels of two nodes alone one can compute the label of their nearest common ancestor. Whether it is possible to distribute the data structure into short labels associated with the nodes is important for several applications such as routing. Therefore, related labeling problems have received a lot of attention recently.Previous optimal algorithms for nearest common ancestor queries work using some mapping from a general tree to a complete binary tree. However, it is not clear how to distribute the data structures obtained using these mappings. We conclude our survey with a new simple algorithm that labels the nodes of a rooted tree such that from the labels of two nodes alone one can compute in constant time the label of their nearest common ancestor. The labels assigned by our algorithm are of size $O(\log n)$ bits where $n$ is the number of nodes in the tree. The algorithm runs in $O(n)$ time.
Keywords
This publication has 29 references indexed in Scilit:
- Compact Routing with Minimum StretchJournal of Algorithms, 2001
- Optimal Pointer Algorithms for Finding Nearest Common Ancestors in Dynamic TreesJournal of Algorithms, 2000
- Shortest paths in digraphs of small treewidth. Part II: Optimal parallel algorithmsTheoretical Computer Science, 1998
- A randomized linear-time algorithm to find minimum spanning treesJournal of the ACM, 1995
- A robust model for finding optimal evolutionary treesAlgorithmica, 1995
- Recursive Star-Tree Parallel Data StructureSIAM Journal on Computing, 1993
- Labelling and Implicit Routing in NetworksThe Computer Journal, 1985
- Storing a Sparse Table with 0 (1) Worst Case Access TimeJournal of the ACM, 1984
- Inferring a Tree from Lowest Common Ancestors with an Application to the Optimization of Relational ExpressionsSIAM Journal on Computing, 1981
- A unifying look at data structuresCommunications of the ACM, 1980