English

Computing palindromes on a trie in linear time

Data Structures and Algorithms 2022-11-11 v2

Abstract

A trie T\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 T\mathcal{T} with nn edges, we show how to compute all distinct palindromes and all maximal palindromes on T\mathcal{T} in O(n)O(n) time, in the case of integer alphabets of size polynomial in nn. This improves the state-of-the-art O(nlogh)O(n \log h)-time algorithms by Funakoshi et al. [PCS 2019], where hh is the height of T\mathcal{T}. Using our new algorithms, the eertree with suffix links for a given trie T\mathcal{T} can readily be obtained in O(n)O(n) time. Further, our trie-based O(n)O(n)-space data structure allows us to report all distinct palindromes and maximal palindromes in a query string represented in the trie T\mathcal{T}, in output optimal time. This is an improvement over an existing (na\"ive) solution that precomputes and stores all distinct palindromes and maximal palindromes for each and every string in the trie T\mathcal{T} separately, using a total O(n2)O(n^2) preprocessing time and space, and reports them in output optimal time upon query.

Keywords

Cite

@article{arxiv.2211.03995,
  title  = {Computing palindromes on a trie in linear time},
  author = {Takuya Mieno and Mitsuru Funakoshi and Shunsuke Inenaga},
  journal= {arXiv preprint arXiv:2211.03995},
  year   = {2022}
}

Comments

accepted to ISAAC 2022

R2 v1 2026-06-28T05:23:40.805Z