Skip to main content

A Memory-Efficient Tree Edit Distance Algorithm

  • Conference paper
Database and Expert Systems Applications (DEXA 2014)

Part of the book series: Lecture Notes in Computer Science ((LNISA,volume 8644))

Included in the following conference series:


Hierarchical data are often modelled as trees. An interesting query identifies pairs of similar trees. The standard approach to tree similarity is the tree edit distance, which has successfully been applied in a wide range of applications. In terms of runtime, the state-of-the-art for the tree edit distance is the RTED algorithm, which is guaranteed to be fast independently of the tree shape. Unfortunately, this algorithm uses twice the memory of the other, slower algorithms. The memory is quadratic in the tree size and is a bottleneck for the tree edit distance computation.

In this paper we present a new, memory efficient algorithm for the tree edit distance. Our algorithm runs at least as fast as RTED, but requires only half the memory. This is achieved by systematically releasing memory early during the first step of the algorithm, which computes a decomposition strategy and is the main memory bottleneck. We show the correctness of our approach and prove an upper bound for the memory usage. Our empirical evaluation confirms the low memory requirements and shows that in practice our algorithm performs better than the analytic guarantees suggest.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
EUR 32.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Similar content being viewed by others


  1. Akutsu, T.: Tree edit distance problems: Algorithms and applications to bioinformatics. IEICE Trans. on Inf. Syst. 93-D(2), 208–218 (2010)

    Article  MathSciNet  Google Scholar 

  2. Aoki, K.F., Yamaguchi, A., Okuno, Y., Akutsu, T., Ueda, N., Kanehisa, M., Mamitsuka, H.: Efficient tree-matching methods for accurate carbohydrate database queries. Genome Informatics 14, 134–143 (2003)

    Google Scholar 

  3. Augsten, N., Barbosa, D., Böhlen, M., Palpanas, T.: Efficient top-k approximate subtree matching in small memory. IEEE TKDE 23(8), 1123–1137 (2011)

    Google Scholar 

  4. Augsten, N., Böhlen, M.H., Gamper, J.: The pq-gram distance between ordered labeled trees. ACM TODS 35(1) (2010)

    Google Scholar 

  5. Chawathe, S.S.: Comparing hierarchical data in external memory. In: VLDB, pp. 90–101 (1999)

    Google Scholar 

  6. Cobena, G., Abiteboul, S., Marian, A.: Detecting changes in XML documents. In: ICDE, pp. 41–52 (2002)

    Google Scholar 

  7. Cohen, S.: Indexing for subtree similarity-search using edit distance. In: SIGMOD, pp. 49–60 (2013)

    Google Scholar 

  8. Dalamagas, T., Cheng, T., Winkel, K.-J., Sellis, T.K.: A methodology for clustering XML documents by structure. Inf. Syst. 31(3), 187–228 (2006)

    Article  Google Scholar 

  9. Demaine, E.D., Mozes, S., Rossman, B., Weimann, O.: An optimal decomposition algorithm for tree edit distance. ACM Trans. on Alg. 6(1) (2009)

    Google Scholar 

  10. Dulucq, S., Touzet, H.: Decomposition algorithms for the tree edit distance problem. J. Discrete Alg. 3(2-4), 448–471 (2005)

    MATH  MathSciNet  Google Scholar 

  11. Finis, J.P., Raiber, M., Augsten, N., Brunel, R., Kemper, A., Färber, F.: RWS-Diff: Flexible and efficient change detection in hierarchical data. In: CIKM, pp. 339–348 (2013)

    Google Scholar 

  12. Garofalakis, M., Kumar, A.: XML stream processing using tree-edit distance embeddings. ACM TODS 30(1), 279–332 (2005)

    Article  Google Scholar 

  13. Guha, S., Jagadish, H.V., Koudas, N., Srivastava, D., Yu, T.: Approximate XML joins. In: SIGMOD, pp. 287–298 (2002)

    Google Scholar 

  14. Heumann, H., Wittum, G.: The tree-edit-distance, a measure for quantifying neuronal morphology. BMC Neuroscience 10(suppl. 1), P89 (2009)

    Article  Google Scholar 

  15. 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)

    Chapter  Google Scholar 

  16. Korn, F., Saha, B., Srivastava, D., Ying, S.: On repairing structural problems in semi-structured data. Proceedings of the VLDB Endowment 6(9) (2013)

    Google Scholar 

  17. Lee, K.-H., Choy, Y.-C., Cho, S.-B.: An efficient algorithm to compute differences between structured documents. IEEE TKDE 16(8), 965–979 (2004)

    Google Scholar 

  18. Lin, Z., Wang, H., McClean, S.: Measuring tree similarity for natural language processing based information retrieval. In: Hopfe, C.J., Rezgui, Y., Métais, E., Preece, A., Li, H. (eds.) NLDB 2010. LNCS, vol. 6177, pp. 13–23. Springer, Heidelberg (2010)

    Chapter  Google Scholar 

  19. Pawlik, M., Augsten, N.: RTED: A robust algorithm for the tree edit distance. Proceedings of the VLDB Endowment, 334–345 (2011)

    Google Scholar 

  20. Springel, V., White, S.D.M., Jenkins, A., Frenk, C.S., Yoshida, N., Gao, L., Navarro, J., Thacker, R., Croton, D., Helly, J., Peacock, J.A., Cole, S., Thomas, P., Couchman, H., Evrard, A., Colberg, J., Pearce, F.: Simulations of the formation, evolution and clustering of galaxies and quasars. Nature 435 (2005)

    Google Scholar 

  21. Tai, K.-C.: The tree-to-tree correction problem. J. ACM 26(3), 422–433 (1979)

    Article  MATH  MathSciNet  Google Scholar 

  22. Zhang, K.: Algorithms for the constrained editing distance between ordered labeled trees and related problems. Pattern Recognition 28(3), 463–474 (1995)

    Article  Google Scholar 

  23. Zhang, K., Shasha, D.: Simple fast algorithms for the editing distance between trees and related problems. SIAM J. Comput. 18(6), 1245–1262 (1989)

    Article  MATH  MathSciNet  Google Scholar 

Download references

Author information

Authors and Affiliations


Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2014 Springer International Publishing Switzerland

About this paper

Cite this paper

Pawlik, M., Augsten, N. (2014). A Memory-Efficient Tree Edit Distance Algorithm. In: Decker, H., Lhotská, L., Link, S., Spies, M., Wagner, R.R. (eds) Database and Expert Systems Applications. DEXA 2014. Lecture Notes in Computer Science, vol 8644. Springer, Cham.

Download citation

  • DOI:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-10072-2

  • Online ISBN: 978-3-319-10073-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics