An Optimal Decomposition Algorithm for Tree Edit Distance

  • Erik D. Demaine
  • Shay Mozes
  • Benjamin Rossman
  • Oren Weimann
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4596)


The edit distance between two ordered rooted 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(n 3)-time algorithm for this problem, improving the previous best O(n 3logn)-time algorithm [7]. Our result requires a novel adaptive strategy for deciding how a dynamic program divides into subproblems, together with a deeper understanding of the previous algorithms for the problem. We 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 Ω(n 2log2 n) [4] to Ω(n 3), matching our algorithm’s running time. Furthermore, we obtain matching upper and lower bounds of \(\Theta(n m^2 (1 + \log \frac{n}{m}))\) when the two trees have sizes m and n where m < n.


Edit Distance Decomposition Algorithm Recursive Call Decomposition Strategy Elementary Operation 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Apostolico, A., Galil, Z. (eds.): Pattern matching algorithms. Oxford University Press, Oxford, UK (1997)zbMATHGoogle Scholar
  2. 2.
    Bille, P.: A survey on tree edit distance and related problems. Theoretical computer science 337, 217–239 (2005)zbMATHCrossRefMathSciNetGoogle Scholar
  3. 3.
    Chawathe, S.S.: Comparing hierarchical data in external memory. In: Proceedings of the 25th International Conference on Very Large Data Bases, pp. 90–101. Edinburgh, Scotland, U.K (1999)Google Scholar
  4. 4.
    Dulucq, S., Touzet, H.: Analysis of tree edit distance algorithms. In: Baeza-Yates, R.A., Chávez, E., Crochemore, M. (eds.) CPM 2003. LNCS, vol. 2676, pp. 83–95. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  5. 5.
    Gusfield, D.: Algorithms on strings, trees and sequences: computer science and computational biology. Cambridge University Press, Cambridge (1997)zbMATHGoogle Scholar
  6. 6.
    Harel, D., Tarjan, R.E.: Fast algorithms for finding nearest common ancestors. SIAM Journal of Computing 13(2), 338–355 (1984)zbMATHCrossRefMathSciNetGoogle Scholar
  7. 7.
    Klein, P.N.: Computing the edit-distance between unrooted ordered trees. In: Bilardi, G., Pietracaprina, A., Italiano, G.F., Pucci, G. (eds.) ESA 1998. LNCS, vol. 1461, pp. 91–102. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  8. 8.
    Klein, P.N., Tirthapura, S., Sharvit, D., Kimia, B.B.: A tree-edit-distance algorithm for comparing simple, closed shapes. In: SODA. Proceedings of the 11th ACM-SIAM Symposium on Discrete Algorithms, pp. 696–704. ACM Press, New York (2000)Google Scholar
  9. 9.
    Moore, P.B.: Structural motifs in RNA. Annual review of biochemistry 68, 287–300 (1999)CrossRefGoogle Scholar
  10. 10.
    Selkow, S.M.: The tree-to-tree editing problem. Information Processing Letters 6(6), 184–186 (1977)zbMATHCrossRefMathSciNetGoogle Scholar
  11. 11.
    Shasha, D., Zhang, K.: Simple fast algorithms for the editing distance between trees and related problems. SIAM Journal of Computing 18(6), 1245–1262 (1989)zbMATHCrossRefMathSciNetGoogle Scholar
  12. 12.
    Shasha, D., Zhang, K.: Fast algorithms for the unit cost editing distance between trees. Journal of Algorithms 11(4), 581–621 (1990)zbMATHCrossRefMathSciNetGoogle Scholar
  13. 13.
    Tai, K.: The tree-to-tree correction problem. Journal of the Association for Computing Machinery (JACM) 26(3), 422–433 (1979)zbMATHMathSciNetGoogle Scholar
  14. 14.
    Valiente, G.: Algorithms on Trees and Graphs. Springer, Heidelberg (2002)zbMATHGoogle Scholar
  15. 15.
    Wagner, R.A., Fischer, M.J.: The string-to-string correction problem. Journal of the ACM 21(1), 168–173 (1974)zbMATHCrossRefMathSciNetGoogle Scholar
  16. 16.
    Waterman, M.S.: Introduction to computational biology: maps, sequences and genomes. chapters 13,14 Chapman and Hall (1995)Google Scholar
  17. 17.
    Zhang, K.: Algorithms for the constrained editing distance between ordered labeled trees and related problems. Pattern Recognition 28(3), 463–474 (1995)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2007

Authors and Affiliations

  • Erik D. Demaine
    • 1
  • Shay Mozes
    • 1
  • Benjamin Rossman
    • 1
  • Oren Weimann
    • 1
  1. 1.MIT Computer Science and Artificial Intelligence Laboratory, 32 Vassar Street, Cambridge, MA 02139USA

Personalised recommendations