A Textbook Solution for Dynamic Strings
Abstract
We consider the problem of maintaining a collection of strings while efficiently supporting splits and concatenations on them, as well as comparing two substrings, and computing the longest common prefix between two suffixes. This problem can be solved in optimal time whp for the updates and worst-case time for the queries, where is the total collection size [Gawrychowski et al., SODA 2018]. We present here a much simpler solution based on a forest of enhanced splay trees (FeST), where both the updates and the substring comparison take amortized time, being the lengths of the strings involved. The longest common prefix of length is computed in amortized time. Our query results are correct whp. Our simpler solution enables other more general updates in amortized time, such as reversing a substring and/or mapping its symbols. We can also regard substrings as circular or as their omega extension.
Cite
@article{arxiv.2403.13162,
title = {A Textbook Solution for Dynamic Strings},
author = {Zsuzsanna Lipták and Francesco Masillo and Gonzalo Navarro},
journal= {arXiv preprint arXiv:2403.13162},
year = {2024}
}
Comments
Accepted at ESA 2024 - Track S