Let $w$ be a string of length $n$. The problem of counting factors crossing a position -- Problem 64 from the textbook ``125 Problems in Text Algorithms'' [Crochemore, Lecroq, and Rytter, 2021] -- asks to count the number $\mathcal{C}(w,k)$ (resp. $\mathcal{N}(w,k)$) of distinct substrings in $w$ that have occurrences containing (resp. not containing) a position $k$ in $w$. The solutions provided in their textbook compute $\mathcal{C}(w,k)$ and $\mathcal{N}(w,k)$ in $O(n)$ time for a single position $k$ in $w$, and thus a direct application would require $O(n^2)$ time for all positions $k = 1, \ldots, n$ in $w$. Their solution is designed for constant-size alphabets. In this paper, we present new algorithms which compute $\mathcal{C}(w,k)$ in $O(n)$ total time for general ordered alphabets, and $\mathcal{N}(w,k)$ in $O(n)$ total time for linearly sortable alphabets,for all positions $k = 1, \ldots, n$ in $w$. We further derive model-dependent optimal bounds by separating the algorithms into preprocessing and linear-time postprocessing: for $\mathcal{C}$ the preprocessing is run reporting, and for $\mathcal{N}$ it is preprocessing based on longest previous non-overlapping factors (LPnF) and longest next factors (LNF). In particular, all values $\mathcal{C}(w,k)$ can be computed in $O(n\log n)$ time over general unordered alphabets in which direct accesses to alphabet characters are restricted to equality tests, and in $O(n\logσ)$ time in the word RAM model, where $σ$ denotes the number of distinct characters occurring in $w$. For $\mathcal{N}(w,k)$, the equality-testing complexity over general unordered alphabets is $Θ(n^2)$. We also show that our upper bounds are optimal for all of the aforementioned alphabet assumptions and computation models.


翻译:设 $w$ 为长度为 $n$ 的字符串。问题“计数跨越某一位置的因子”——源自教科书《125个文本算法问题》([Crochemore, Lecroq, and Rytter, 2021])中的第64题——要求统计 $w$ 中具有包含(或不包含)位置 $k$ 的出现次数的不同子串数量,分别记为 $\mathcal{C}(w,k)$ 和 $\mathcal{N}(w,k)$。该教科书提供的解法可在 $O(n)$ 时间内计算 $w$ 中单个位置 $k$ 的 $\mathcal{C}(w,k)$ 和 $\mathcal{N}(w,k)$,因此直接应用于 $w$ 中所有位置 $k = 1, \ldots, n$ 将需要 $O(n^2)$ 时间。该解法针对常数大小字母表设计。本文提出新算法,可在 $O(n)$ 总时间内计算一般有序字母表上的 $\mathcal{C}(w,k)$,并在 $O(n)$ 总时间内计算线性可排序字母表上的 $\mathcal{N}(w,k)$,其中 $k$ 取遍 $w$ 中所有位置 $k = 1, \ldots, n$。我们进一步通过将算法分为预处理和线性时间后处理来推导模型依赖的最优界:对于 $\mathcal{C}$,预处理基于游程报告;对于 $\mathcal{N}$,预处理基于最长前次非重叠因子(LPnF)和最长后次因子(LNF)。特别地,在一般无序字母表(仅允许通过相等性测试访问字符)上,所有 $\mathcal{C}(w,k)$ 值可在 $O(n\log n)$ 时间内计算;在字RAM模型上,可在 $O(n\logσ)$ 时间内计算,其中 $σ$ 表示 $w$ 中出现的不同字符数量。对于 $\mathcal{N}(w,k)$,在一般无序字母表上的相等性测试复杂度为 $Θ(n^2)$。我们还证明,上述所有字母表假设和计算模型下的上界均为最优。

0
下载
关闭预览

相关内容

索邦大学121页博士论文《时间序列中的无监督异常检测》
专知会员服务
104+阅读 · 2022年7月25日
【CVPR2021】跨模态检索的概率嵌入
专知
17+阅读 · 2021年3月2日
面试题:数组中子序列的个数
七月在线实验室
15+阅读 · 2019年6月26日
论文盘点:CVPR 2019 - 文本检测专题
PaperWeekly
14+阅读 · 2019年5月31日
无监督元学习表示学习
CreateAMind
27+阅读 · 2019年1月4日
R语言时间序列分析
R语言中文社区
12+阅读 · 2018年11月19日
跨越注意力:Cross-Attention
我爱读PAMI
172+阅读 · 2018年6月2日
R语言之数据分析高级方法「时间序列」
R语言中文社区
17+阅读 · 2018年4月24日
用于数学的 10 个优秀编程语言
算法与数据结构
13+阅读 · 2018年1月5日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
6+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
7+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
4+阅读 · 6月17日
相关VIP内容
索邦大学121页博士论文《时间序列中的无监督异常检测》
专知会员服务
104+阅读 · 2022年7月25日
相关资讯
【CVPR2021】跨模态检索的概率嵌入
专知
17+阅读 · 2021年3月2日
面试题:数组中子序列的个数
七月在线实验室
15+阅读 · 2019年6月26日
论文盘点:CVPR 2019 - 文本检测专题
PaperWeekly
14+阅读 · 2019年5月31日
无监督元学习表示学习
CreateAMind
27+阅读 · 2019年1月4日
R语言时间序列分析
R语言中文社区
12+阅读 · 2018年11月19日
跨越注意力:Cross-Attention
我爱读PAMI
172+阅读 · 2018年6月2日
R语言之数据分析高级方法「时间序列」
R语言中文社区
17+阅读 · 2018年4月24日
用于数学的 10 个优秀编程语言
算法与数据结构
13+阅读 · 2018年1月5日
相关基金
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员