Tree edit distance computation improved with faster approximate and dynamic algorithms
Tree Edit Distance: Near-Linear-Time Approximate, Sublinear, and Dynamic
Data Structures and Algorithms
Summary
Tree edit distance measures how different two tree-structured data sets are by counting changes needed to turn one into the other. The authors developed new algorithms that can estimate this distance much faster than before, even nearly as fast as similar string comparison algorithms. Their methods work well for quick approximations, sublinear-time calculations, and updates when trees change dynamically. These improvements help bring hierarchical data comparisons closer to the efficiency of string comparisons.
What this means in practice
- •For software engineers: Update and query hierarchical data structures like XML or JSON trees efficiently when data changes over time.
- •For database developers: Implement fast approximate similarity searches over tree-structured hierarchical data to speed up querying large data sets.
Authors
Bingbing Hu, Tomasz Kociumaka, Jakob Nogler, Barna Saha
Abstract
Tree edit distance (TED), the analog of string edit distance (ED) for hierarchical data, is the minimum number of node insertions, deletions, and substitutions transforming one labeled rooted ordered tree into another. We narrow polynomial gaps between TED and ED in near-linear-time approximation, sublinear algorithms, and dynamic algorithms. We give an $n^{o(1)}$-approximation in $O(n)$ time and, for every $0<δ<1$, a $(\log n)^{O(1/δ)}$-approximation in $O(n^{1+δ})$ time. This improves the previous near-linear-time $O(\sqrt n)$-approximation [Boroujeni et al., STOC'19] and brings TED to parity with ED in this regime up to polylogarithmic factors. With query access to the balanced-parentheses (Euler-tour) representation of the input trees, we give the first sublinear-time TED algorithm: for every $τ\in[1,n]$, it computes a $τn^{o(1)}$-approximation of $1+\mathrm{ted}$ in $O(n/τ)$ time. For dynamic TED, we give an exact algorithm with amortized update time $\tilde{O}(k^7)$ and a $(1+\varepsilon)$-approximation with amortized update time $\tilde{O}_{\varepsilon}(k)$, where $k$ caps the distance that must be reported. The exact algorithm is the first to beat recomputation in a nontrivial parameter regime. The approximation improves prior dynamic guarantees [Das et al., FOCS'25] and cannot be significantly improved in any parameter regime without a breakthrough for static $(1+\varepsilon)$-approximation of ED. All results use dynamic programming on a new hierarchical tree decomposition, analogous to partitioning strings into blocks of geometrically decreasing sizes. It combines structural properties previously achieved only in isolation, providing a framework for transferring algorithmic ideas from ED to TED, with additional ingredients addressing the obstacles in each computational setting.