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 et al., SODA 2018]。本文提出一种基于增强伸展树森林(FeST)的更简洁解法,其更新操作与子串比较均摊时间复杂度为 $\mathcal{O}(\log n)$(其中 $n$ 为涉及字符串的长度)。长度为 $\ell$ 的最长公共前缀计算具有 $\mathcal{O}(\log n + \log^2\ell)$ 的均摊时间复杂度。所有查询结果均以高概率保证正确性。该简洁解法可进一步支持 $\mathcal{O}(\log n)$ 均摊时间复杂度的广义更新操作,例如子串反转和/或字符映射。我们还可将子串视为循环字符串或其无限扩展形式进行处理。