We study the problem of finding lowest common ancestors (LCA) in trees and directed acyclic graphs (DAGs). Specifically, we extend the LCA problem to DAGs and study the LCA variants that arise in this general setting. We begin with a clear exposition of Berkman and Vishkin's simple optimal algorithm for LCA in trees. Their ideas lay the foundation for our work on LCA problems in DAGs. We present an algorithm that finds all-pairs-representative LCA in DAGs in O(n 2.688 ) operations, provide a transitiveclosure lower bound for the all-pairs-representative-LCA problem, and develop an LCA-existence algorithm that preprocesses the DAG in transitive-closure time. We also present a suboptimal but practical O(n 3 ) algorithm for all-pairs-representative LCA in DAGs that uses ideas from the optimal algorithms in trees ✩ This work appeared in preliminary form in publications: [M.A. Bender, M. Farach-Colton, The LCA problem revisited, in: Latin American Theoretical Informatics, April 2000, pp. 88-94. [2]] and [M.A. Bender, G. Pemmasani, S. Skiena, P. Sumazin, Finding least common ancestors in directed acyclic graphs, in: 76 M. A. Bender et al. / Journal of Algorithms 57 (2005) [75][76][77][78][79][80][81][82][83][84][85][86][87][88][89][90][91][92][93][94] and DAGs. Our results reveal a close relationship between the LCA, all-pairs-shortest-path, and transitiveclosure problems.We conclude the paper with a short experimental study of LCA algorithms in trees and DAGs. Our experiments and source code demonstrate the elegance of the preprocessing-query algorithms for LCA in trees. We show that for most trees the suboptimal Θ(n log n)-preprocessing Θ(1)-query algorithm should be preferred, and demonstrate that our proposed O(n 3 ) algorithm for all-pairs-representative LCA in DAGs performs well in both low and high density DAGs. 2005 Elsevier Inc. All rights reserved.
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.