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. 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$为所涉字符串长度。长度为$\ell$的最长公共前缀可在均摊时间$\mathcal{O}(\log n + \log^2\ell)$内计算完成。我们的查询结果以高概率正确。该简化解法还支持其他更通用的更新操作(均摊时间$\mathcal{O}(\log n)$),例如反转子串和/或映射其符号。我们还可将子串视为循环串或其omega扩展。