Lowest common ancestors in trees and directed acyclic graphs

被引:138
作者
Bender, MA
Farach-Colton, M
Pemmasani, G
Skiena, S
Sumazin, P
机构
[1] Portland State Univ, Dept Comp Sci, Portland, OR 97207 USA
[2] SUNY Stony Brook, Dept Comp Sci, Stony Brook, NY 11794 USA
[3] Rutgers State Univ, Dept Comp Sci, Piscataway, NJ 08855 USA
来源
JOURNAL OF ALGORITHMS-COGNITION INFORMATICS AND LOGIC | 2005年 / 57卷 / 02期
基金
美国国家科学基金会;
关键词
lowest common ancestor (LCA); directed cyclic graph (DAG); range minimum query (RMQ); shortest path; Cartesian tree;
D O I
10.1016/j.jalgor.2005.08.001
中图分类号
TP301 [理论、方法];
学科分类号
081202 ;
摘要
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 Jay 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 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(n(3)) 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 Theta (n log n)-preprocessing Theta (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. (c) 2005 Elsevier Inc. All rights reserved.
引用
收藏
页码:75 / 94
页数:20
相关论文
共 29 条
[1]   EFFICIENT IMPLEMENTATION OF LATTICE OPERATIONS [J].
AITKACI, H ;
BOYER, R ;
LINCOLN, P ;
NASR, R .
ACM TRANSACTIONS ON PROGRAMMING LANGUAGES AND SYSTEMS, 1989, 11 (01) :115-146
[2]  
[Anonymous], 1987, P 19 ANN ACM S THEOR
[3]   The LCA problem revisited [J].
Bender, MA ;
Farach-Colton, M .
LATIN 2000: THEORETICAL INFORMATICS, 2000, 1776 :88-94
[4]  
BENDER MA, 2001, P 12 ANN ACM SIAM S, P235
[5]   FINDING LEVEL-ANCESTORS IN TREES [J].
BERKMAN, O ;
VISHKIN, U .
JOURNAL OF COMPUTER AND SYSTEM SCIENCES, 1994, 48 (02) :214-230
[6]   RECURSIVE STAR-TREE PARALLEL DATA STRUCTURE [J].
BERKMAN, O ;
VISHKIN, U .
SIAM JOURNAL ON COMPUTING, 1993, 22 (02) :221-242
[7]  
BILMES J, 1977, P INT C SUP VIENN AU
[8]  
Bilmes J., 1997, P ICASSP MUN GERM AP, V5, P4153
[9]   On-line algorithms for orders [J].
Bouchitte, V ;
Rampon, JX .
THEORETICAL COMPUTER SCIENCE, 1997, 175 (02) :225-238
[10]  
Cole R, 1999, PROCEEDINGS OF THE TENTH ANNUAL ACM-SIAM SYMPOSIUM ON DISCRETE ALGORITHMS, P235