An O(n3)-Time Algorithm for Tree Edit Distance

Abstract

The edit distance between two ordered trees with vertex labels is the minimum cost of transforming one tree into the other by a sequence of elementary operations consisting of deleting and relabeling existing nodes, as well as inserting new nodes. In this paper, we present a worst-case O(n3)-time algorithm for this problem, improving the previous best O(n3 n)-time algorithm~Klein. Our result requires a novel adaptive strategy for deciding how a dynamic program divides into subproblems (which is interesting in its own right), together with a deeper understanding of the previous algorithms for the problem. We also prove the optimality of our algorithm among the family of decomposition strategy algorithms--which also includes the previous fastest algorithms--by tightening the known lower bound of (n22 n)~Touzet to (n3), matching our algorithm's running time. Furthermore, we obtain matching upper and lower bounds of (n m2 (1 + nm)) when the two trees have different sizes m and~n, where m < n.

0

Turn this paper into a full lesson

ArcXiv compiles a staged curriculum from this paper: 8-12 lessons across beginner → advanced, synthesised section guides, visuals, flashcards, a quiz, exercises, and on-demand deep dives per section. Grounded in the abstract, never invented.

Discussion (0)

Sign in to join the discussion.

Loading comments…