We consider the problems of computing maximal palindromes and distinct palindromes in a trie. A trie is a natural generalization of a string, which can be seen as a single-path tree. There is a linear-time offline algorithm to compute maximal palindromes and distinct palindromes in a given (static) trie whose edge-labels are drawn from a linearly-sortable alphabet [Mieno et al., ISAAC 2022]. In this paper, we tackle problems of palindrome enumeration on dynamic tries which support leaf additions and leaf deletions. We propose the first sub-quadratic algorithms to enumerate palindromes in a dynamic trie. For maximal palindromes, we propose an algorithm that runs in $O(N \min(\log h, σ))$ time and uses $O(N)$ space, where $N$ is the maximum number of edges in the trie, $σ$ is the size of the alphabet, and $h$ is the height of the trie. For distinct palindromes, we develop several online algorithms based on different algorithmic frameworks, including approaches using the EERTREE (a.k.a. palindromic tree) and the suffix tree of a trie. These algorithms support leaf insertions and deletions in the trie and achieve different time and space trade-offs. Furthermore, as a by-product, we present online algorithms to construct the suffix tree and the EERTREE of the input trie, which is of independent interest.
翻译:本文研究在Trie(字典树)中计算最大回文串与不同回文串的问题。Trie是字符串的自然推广,可视为单路径树的扩展。对于边标签来自线性可排序字母表的给定(静态)Trie,存在线性时间离线算法可计算其最大回文串与不同回文串[Mieno等,ISAAC 2022]。本文致力于在支持叶子节点动态增删的Trie上进行回文串枚举。我们提出了首个亚二次时间算法以枚举动态Trie中的回文串。针对最大回文串,我们提出一种时间复杂度为$O(N \min(\log h, σ))$、空间复杂度为$O(N)$的算法,其中$N$为Trie中边的最大数量,$σ$为字母表大小,$h$为Trie高度。针对不同回文串,我们基于多种算法框架开发了若干在线算法,包括采用EERTREE(亦称回文树)和Trie后缀树的方法。这些算法支持Trie中叶子节点的插入与删除,并实现了不同的时空权衡。此外,作为副产品,我们提出了构建输入Trie的后缀树与EERTREE的在线算法,该成果具有独立的研究价值。