Dynamic Dyck and Tree Edit Distance: Decompositions and Reductions to String Edit Distance
Debarati Das, Jacob Gilbert, MohammadTaghi Hajiaghayi, Tomasz Kociumaka, Barna Saha
TL;DR
This work advances dynamic algorithms for two foundational structured-data distances, Dyck edit distance and tree edit distance, by reducing both to dynamic string edit distance with subpolynomial updates. It introduces a new dynamic heavy-light decomposition that preserves heavy paths and enables polylog updates, and develops static and dynamic reductions from trees and Dyck strings to strings and then to string edit distance. The main results include (i) a subpolynomial-update dynamic algorithm achieving polylog-approximation for Dyck distance, (ii) a dynamic $ ilde{O}( ext{sqrt}(n))$-approximation for tree edit distance, and (iii) near-linear static and polylog-dynamic decompositions yielding improved bounds, plus exact dynamic algorithms for bounded-distance regimes. Together, these techniques deliver practical, scalable maintenance of structured-data distances under updates, with potential impact on XML/JSON editing, RNA structure analysis, and related domains.
Abstract
We present the first dynamic algorithms for Dyck and tree edit distances with subpolynomial update times. Dyck edit distance measures how far a parenthesis string is from a well-parenthesized expression, while tree edit distance quantifies the minimum number of node insertions, deletions, and substitutions required to transform one rooted, ordered, labeled tree into another. Despite extensive study, no prior work has addressed efficient dynamic algorithms for these problems, which naturally arise in evolving structured data such as LaTeX documents, JSON or XML files, and RNA secondary structures. Our main contribution is a set of reductions and decompositions that transform Dyck and tree edit distance instances into efficiently maintainable string edit distance instances, which can be approximated within a $n^{o(1)}$ factor in $n^{o(1)}$ update time. For Dyck edit distance, our reduction incurs only polylogarithmic overheads in approximation and update time, yielding an $n^{o(1)}$-approximation with $n^{o(1)}$ updates. For tree edit distance, we introduce a new static reduction that improves the best-known approximation ratio from $n^{3/4}$ to $\tilde{O}(\sqrt{n})$ and removes the restriction to constant-degree trees. Extending this reduction dynamically achieves $n^{1/2+o(1)}$ approximation with $n^{o(1)}$ update time. A key component is a dynamic maintenance algorithm for history-independent heavy-light decompositions, of independent interest. We also provide a novel static and dynamic decomposition achieving an $O(k \log n)$-approximation when the tree edit distance is at most $k$. Combined with the trivial bound $k \le n$, this yields a dynamic deterministic $O(\sqrt{n \log n})$-approximation. In the static setting, our algorithm runs in near-linear time; dynamically, it requires only polylogarithmic updates, improving on prior linear-time static $O(\sqrt{n})$-approximation.
