一种针对动态字符串的教科书式解决方案
A Textbook Solution for Dynamic Strings
AI总结:
针对动态字符串集合的维护问题,提出基于增强伸展树森林(FeST)的简洁方案,在保证查询结果高概率正确的同时,实现更优的均摊时间复杂度,并支持更多通用更新操作。
摘要:
我们研究了维护字符串集合的问题,该集合需高效支持字符串的拆分与拼接,以及两个子串的比较、两个后缀的最长公共前缀计算。此问题可在最优时间复杂度下求解:更新操作以高概率(whp)达到$\u003cspan style="font-family: italic;"\u003eO\u003c/span\u003e(\n N)$,查询操作最坏情况时间为$\u003cspan style="font-family: italic;"\u003eO\u003c/span\u003e(1)$,其中$N$为集合总规模[Gawrychowski等人,SODA 2018]。我们在此提出一种基于增强伸展树森林(FeST)的更简洁解决方案,其中更新操作和子串比较的均摊时间复杂度均为$\u003cspan style="font-family: italic;"\u003eO\u003c/span\u003e(\n n)$,$n$为涉及的字符串长度。长度为$\u2113$的最长公共前缀的计算均摊时间为$\u003cspan style="font-family: italic;"\u003eO\u003c/span\u003e(\n n + \n^2\u2113)$。我们的查询结果以高概率(whp)正确。这种更简洁的方案还能以$\u003cspan style="font-family: italic;"\u003eO\u003c/span\u003e(\n n)$的均摊时间支持其他更通用的更新操作,例如反转子串和/或映射其符号。我们还可将子串视为循环串或其ω扩展。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。