Finding Gapped Palindromes Online

A string s is said to be a gapped palindrome iff \(s = xyx^R\) for some strings x, y such that \(|x| \ge 1\), \(|y| \ge 2\), and \(x^R\) denotes the reverse image of x. In this paper we consider two kinds of gapped palindromes, and present efficient online algorithms to compute these gapped palindromes occurring in a string. First, we show an online algorithm to find all maximal g-gapped palindromes with fixed gap length \(g \ge 2\) in a string of length n in \(O(n \log \sigma )\) time and O(n) space, where \(\sigma \) is the alphabet size. Second, we show an online algorithm to find all maximal length-constrained gapped palindromes with arm length at least \( A \ge 1\) and gap length in range \([ g _{\min }, g _{\max }]\) in \(O(n(\frac{ g _{\max }- g _{\min }}{ A } + \log \sigma ))\) time and O(n) space. We also show that if \( A \) is a constant, then there exists a string of length n which contains \(\varOmega (n( g _{\max }- g _{\min }))\) maximal LCGPs, which implies we cannot hope for a significant speed-up in the worst case.