Fast algorithms for computing tree LCS

  • Authors:
  • Shay Mozes;Dekel Tsur;Oren Weimann;Michal Ziv-Ukelson

  • Affiliations:
  • Brown University, Providence, RI 02912-1910, USA;Ben-Gurion University of the Negev, Beer Sheva, Israel;Massachusetts Institute of Technology, Cambridge, MA 02139, USA;Ben-Gurion University of the Negev, Beer Sheva, Israel

  • Venue:
  • Theoretical Computer Science
  • Year:
  • 2009

Quantified Score

Hi-index 5.23

Visualization

Abstract

The LCS of two rooted, ordered, and labeled trees F and G is the largest forest that can be obtained from both trees by deleting nodes. We present algorithms for computing tree LCS which exploit the sparsity inherent to the tree LCS problem. Assuming G is smaller than F, our first algorithm runs in time O(r@?height(F)@?height(G)@?lglg|G|), where r is the number of pairs (v@?F,w@?G) such that v and w have the same label. Our second algorithm runs in time O(Lrlgr@?lglg|G|), where L is the size of the LCS of F and G. For this algorithm we present a novel three-dimensional alignment graph. Our third algorithm is intended for the constrained variant of the problem in which only nodes with zero or one children can be deleted. For this case we obtain an O(rhlglg|G|) time algorithm, where h=height(F)+height(G).