[论文解读] Algorithms to Compute the Lyndon Array
本文提出了五种计算字符串Lyndon数组的算法,其中包括两种新颖的$O(n\log n)$时间复杂度方法,这些方法避免了后缀数组等全局数据结构。主要贡献在于提出一个猜想:可能存在一种线性时间、基础性的Lyndon数组计算算法,该猜想得到了实验结果的支持,表明大多数算法在实践中运行时间接近线性。
We first describe three algorithms for computing the Lyndon array that have been suggested in the literature, but for which no structured exposition has been given. Two of these algorithms execute in quadratic time in the worst case, the third achieves linear time, but at the expense of prior computation of both the suffix array and the inverse suffix array of x. We then go on to describe two variants of a new algorithm that avoids prior computation of global data structures and executes in worst-case n log n time. Experimental evidence suggests that all but one of these five algorithms require only linear execution time in practice, with the two new algorithms faster by a small factor. We conjecture that there exists a fast and worst-case linear-time algorithm to compute the Lyndon array that is also elementary (making no use of global data structures such as the suffix array).
研究动机与目标
- 系统分析并呈现现有及新型算法以计算Lyndon数组,该数组对于高效计算字符串中的运行(runs)至关重要。
- 开发并评估不依赖后缀数组等重型全局数据结构的Lyndon数组计算算法。
- 基于实验性能和理论分析,探究是否存在一种线性时间、基础性的Lyndon数组计算算法。
- 比较不同方法在时间复杂度和各类字符串类型下的常数因子方面的实际效率。
- 对以往仅以非正式或缺乏结构化分析方式描述的算法提供全面的阐述。
提出的方法
- 提出三种现有算法:两种最坏情况时间复杂度为$O(n^2)$,一种使用后缀数组和逆后缀数组实现$O(n)$时间复杂度。
- 基于范围比较的新型算法NSV$^*$,提出两种新变体,利用Parikh向量实现$O(\sigma)$时间复杂度的范围比较。
- 使用Parikh向量$P_r[1..\sigma]$表示范围内容,使子串的字典序比较在$O(\sigma)$时间内完成,而非$O(\ell)$。
- 采用基于栈的活动范围跟踪机制,并利用$\text{nextequal}[j]$检测周期性,避免冗余比较。
- 实现两种版本:NPNSV$^*$(不使用Parikh向量)和PNSV$^*$(使用Parikh向量),两者均实现最坏情况$O(n\log n)$时间复杂度。
- 通过预处理在$O(n)$时间内计算Parikh向量,从而在主计算阶段实现高效的范围比较。
实验结果
研究问题
- RQ1是否可以仅使用基础数据结构、不构建后缀数组,在$O(n)$时间内计算Lyndon数组?
- RQ2在不同类型的字符串(包括随机字符串和周期性字符串)上,现有及新算法在Lyndon数组计算中的实际性能如何?
- RQ3使用Parikh向量如何影响Lyndon数组计算算法的效率和最坏情况复杂度?
- RQ4使用后缀数组的算法与不使用后缀数组的算法之间是否存在显著的性能差距,特别是在常数因子和缓存行为方面?
- RQ5在大型输入上,新的$O(n\log n)$时间复杂度算法是否实际优于现有的$O(n^2)$时间复杂度方法?
主要发现
- 在测试的五种算法中,除MaxLyn及两种新型NSV$^*$变体外,其余均表现出接近线性的实际运行时间,尽管其最坏情况时间复杂度各不相同。
- 使用Parikh向量的PNSV$^*$变体在小型二进制字符串上比MaxLyn慢约10倍,但在较长字符串上仍保持竞争力。
- 在随机二进制字符串上,PNSV$^*$和NPNSV$^*$是最快的,比MaxLyn快2–3倍,表明其在平均输入下表现优异。
- 在高度周期性的字符串上,MaxLyn比NSV$^*$变体快约相同幅度,表明算法选择取决于输入结构。
- NSV$^*$的最坏情况输入需要$O(n\log n)$次范围匹配,证实了理论上的$O(n\log n)$时间复杂度,而使用Parikh向量的版本继承了该复杂度,仅增加$O(\sigma)$因子。
- 尽管理论最坏情况复杂度存在限制,但实验结果表明,可能存在一种线性时间、基础性的Lyndon数组计算算法,从而支持作者提出的该类算法存在的猜想。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。