Table of Contents
Fetching ...

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.

Dynamic Dyck and Tree Edit Distance: Decompositions and Reductions to String Edit Distance

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 -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 factor in update time. For Dyck edit distance, our reduction incurs only polylogarithmic overheads in approximation and update time, yielding an -approximation with updates. For tree edit distance, we introduce a new static reduction that improves the best-known approximation ratio from to and removes the restriction to constant-degree trees. Extending this reduction dynamically achieves approximation with 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 -approximation when the tree edit distance is at most . Combined with the trivial bound , this yields a dynamic deterministic -approximation. In the static setting, our algorithm runs in near-linear time; dynamically, it requires only polylogarithmic updates, improving on prior linear-time static -approximation.
Paper Structure (48 sections, 49 theorems, 23 equations, 11 figures, 2 tables, 4 algorithms)

This paper contains 48 sections, 49 theorems, 23 equations, 11 figures, 2 tables, 4 algorithms.

Key Result

Theorem 1.1

(Informal) There exists a randomized dynamic algorithm, that maintains a $\text{poly}\log n$-approximation of Dyck edit distance (correctly with high probability against an oblivious adversary) for an (initially empty) string $X$ of length at most $n$ undergoing edits. The expected amortized update

Figures (11)

  • Figure 1: (a) Example of a graph of heights of parentheses in a given input string from DBLP:conf/soda/FriedGKKPS22. (b) The tree representation $T_X$ of parenthesis string $X =$$\texttt{(}_1$$\texttt{(}_2$$\texttt{(}_3$$\texttt{)}_3$$\texttt{)}_2$$\texttt{(}_4$$\texttt{)}_4$$\texttt{)}_1$$\texttt{(}_5$$\texttt{)}_5$ where matching indices in the subscripts of the parentheses indicate pairs of twins. The path containing nodes labeled 1, 2, 3 corresponds to string $\texttt{(}_1$$\texttt{(}_2$$\texttt{(}_3$$\texttt{)}_3$$\texttt{)}_2$$\texttt{)}_1$.
  • Figure 2: Two instances the tree edit distance problem. (a) Trees $T_1$ and $T_2$ with $A_i \ne A_j$, $B_i \ne B_j$ for $i \ne j$. (b) Trees $T_1$ and $T_2$ with repeating subtrees $A$ and $B$ to the left and right, respectively, of the center path.
  • Figure 3: An example of a context $(\mathsf{P}_{}(F)[o(w) \mathinner{.\,.} o(u)],\mathsf{P}_{}(F)[c(u) \mathinner{.\,.} c(w)])$ for the subtree of node $w$ in a forest $\mathcal{F}$ formed by excluding the subtree of node $u$. The left part of the context, depicted in blue, is $\mathsf{P}_{}(F)[o(w) \mathinner{.\,.} o(u)]$ and the right part of the context, depicted in orange, is $\mathsf{P}_{}(F)[c(u) \mathinner{.\,.} c(w)]$.
  • Figure 4: An example of partitioning a forest piece $\mathsf{P}_{}(F)[i \mathinner{.\,.} j)$. The six parts as defined in the proof of Lemma \ref{['lem:partitionpiece']} are colored 1 - blue, 2 - orange, 3 - magenta, 4 - uncolored, 5 - red, 6 - green.
  • Figure 5: An example of a context $\sigma$ and forest $\mathcal{G}$ for which $\mathsf{HasMatch}(\sigma) = \mathsf{true}$. The arithmetic progression of depths for the left and right part of $\sigma$ are $f_1(i) = 2i + 1$, $f_2(i) = i$, respectively. Green colored nodes represent root nodes of valid matching contexts corresponding to intersections in $f_1$ and $f_2$.
  • ...and 6 more figures

Theorems & Definitions (126)

  • Theorem 1.1
  • Theorem 1.2
  • Theorem 1.3
  • Definition 2.1
  • Definition 2.3: Dyck edit distance
  • Definition 2.4: Alignments
  • Definition 2.6: Tree Alignments
  • proof
  • proof
  • Definition 3.1: Heavy-Light Decomposition
  • ...and 116 more