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 $\mathcal{O}(\log N)$ whp for the updates and $\mathcal{O}(1)$ worst-case time for the queries, where $N$ 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 $\mathcal{O}(\log n)$ amortized time, $n$ being the lengths of the strings involved, and not the total length $N$ of the strings in the collection. The longest common prefix of length $\ell$ is computed in $\mathcal{O}(\log n + \log^2\ell)$ amortized time. Our query results are correct whp. Our simpler solution enables other more general updates in $\mathcal{O}(\log n)$ amortized time, such as reversing a substring and/or mapping its symbols. We can also regard substrings as circular or as their omega extension.
翻译:我们考虑维护一组字符串的问题,同时高效支持对字符串的分割与拼接操作,以及比较两个子串和计算两个后缀的最长公共前缀。该问题已知的最优解法能在更新操作上以高概率达到 $\mathcal{O}(\log N)$ 时间、查询操作上达到最坏情况 $\mathcal{O}(1)$ 时间,其中 $N$ 为集合总大小 [Gawrychowski 等,SODA 2018]。本文提出一种基于增强伸展树森林(FeST)的更简单解法,其中更新操作和子串比较均摊时间复杂度为 $\mathcal{O}(\log n)$,这里 $n$ 为所涉及字符串的长度,而非集合中所有字符串的总长度 $N$。长度为 $\ell$ 的最长公共前缀可在均摊 $\mathcal{O}(\log n + \log^2\ell)$ 时间内计算。我们的查询结果以高概率正确。该更简单解法还能在均摊 $\mathcal{O}(\log n)$ 时间内支持其他更通用的更新操作,例如反转子串和/或映射其符号。我们还可以将子串视为循环字符串或其 omega 扩展。