在线性时间内计算Trie上的回文数
Computing palindromes on a trie in linear time
摘要:
Trie树$\mathcal{T}$是一棵有根树,每条边由字母表中的单个字符标记,并且来自同一节点的外出边的标签是相互不同的。给定一个具有$n$边的trie树$\mathcal{T}$,在$n$中整数字母表的大小为多项式的情况下,给出了如何在$O(n)$时间内计算$\mathcal{T}$上所有不同的回文和所有最大的回文.这改进了Funakoshi等人[PCS 2019]的最新$O(n \log h)$时间算法,其中$h$是$\mathcal{T}$的高度。利用我们的新算法,可以在$O(n)$时间内容易地获得给定trie树$\mathcal{T}$的具有后缀链接的eertree。此外,我们的基于trie的$O(n)$空间数据结构允许我们在输出最佳时间报告所有不同的回文和最大回文在trie $\mathcal{T}$中表示的查询字符串。这是对现有(朴素)解决方案的改进,该解决方案使用总的$O(n^2)$预处理时间和空间,分别为trie $\mathcal{T}$中的每个字符串预先计算和存储所有不同的回文和最大回文,并在查询时在输出最佳时间中报告它们。
英文摘要:
A trie $\mathcal{T}$ is a rooted tree such that each edge is labeled by a single character from the alphabet, and the labels of out-going edges from the same node are mutually distinct. Given a trie $\mathcal{T}$ with $n$ edges, we show how to compute all distinct palindromes and all maximal palindromes on $\mathcal{T}$ in $O(n)$ time, in the case of integer alphabets of size polynomial in $n$. This improves the state-of-the-art $O(n \log h)$-time algorithms by Funakoshi et al. [PCS 2019], where $h$ is the height of $\mathcal{T}$. Using our new algorithms, the eertree with suffix links for a given trie $\mathcal{T}$ can readily be obtained in $O(n)$ time. Further, our trie-based $O(n)$-space data structure allows us to report all distinct palindromes and maximal palindromes in a query string represented in the trie $\mathcal{T}$, in output optimal time. This is an improvement over an existing (naïve) solution that precomputes and stores all distinct palindromes and maximal palindromes for each and every string in the trie $\mathcal{T}$ separately, using a total $O(n^2)$ preprocessing time and space, and reports them in output optimal time upon query.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。