Lowest common ancestors in trees and directed acyclic graphs

Michael A. Bender, Martín Farach-Colton, Giridhar Pemmasani, Steven Skiena, Pavel Sumazin

    Research output: Contribution to journalArticlepeer-review

    Abstract

    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 Õ(n2.688) operations, provide a transitive-closure 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(n3) algorithm for all-pairs-representative LCA in DAGs that uses ideas from the optimal algorithms in trees and DAGs. Our results reveal a close relationship between the LCA, all-pairs-shortest-path, and transitive-closure 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 Θ(nlogn)-preprocessing Θ(1)-query algorithm should be preferred, and demonstrate that our proposed O(n3) algorithm for all-pairs-representative LCA in DAGs performs well in both low and high density DAGs.

    Original languageEnglish (US)
    Pages (from-to)75-94
    Number of pages20
    JournalJournal of Algorithms
    Volume57
    Issue number2
    DOIs
    StatePublished - Nov 2005

    Keywords

    • Cartesian tree
    • Directed cyclic graph (DAG)
    • Lowest common ancestor (LCA)
    • Range minimum query (RMQ)
    • Shortest path

    ASJC Scopus subject areas

    • Control and Optimization
    • Computational Mathematics
    • Computational Theory and Mathematics

    Fingerprint

    Dive into the research topics of 'Lowest common ancestors in trees and directed acyclic graphs'. Together they form a unique fingerprint.

    Cite this