English

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

Data Structures and Algorithms 2025-10-21 v1

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 no(1)n^{o(1)} factor in no(1)n^{o(1)} update time. For Dyck edit distance, our reduction incurs only polylogarithmic overheads in approximation and update time, yielding an no(1)n^{o(1)}-approximation with no(1)n^{o(1)} updates. For tree edit distance, we introduce a new static reduction that improves the best-known approximation ratio from n3/4n^{3/4} to O~(n)\tilde{O}(\sqrt{n}) and removes the restriction to constant-degree trees. Extending this reduction dynamically achieves n1/2+o(1)n^{1/2+o(1)} approximation with no(1)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(klogn)O(k \log n)-approximation when the tree edit distance is at most kk. Combined with the trivial bound knk \le n, this yields a dynamic deterministic O(nlogn)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(n)O(\sqrt{n})-approximation.

Keywords

Cite

@article{arxiv.2510.17799,
  title  = {Dynamic Dyck and Tree Edit Distance: Decompositions and Reductions to String Edit Distance},
  author = {Debarati Das and Jacob Gilbert and MohammadTaghi Hajiaghayi and Tomasz Kociumaka and Barna Saha},
  journal= {arXiv preprint arXiv:2510.17799},
  year   = {2025}
}

Comments

Full version of a FOCS 2025 paper