Double-Ended Palindromic Trees: A Linear-Time Data Structure and Its Applications

Qisheng Wang, Ming Yang, Xinrui ZhuarXiv 2022 · arXiv · OpenReview

TL;DR

This paper introduces the "double-ended eertree," a novel data structure that efficiently handles dynamic string operations (adding/removing characters from both ends) while tracking all palindromic substrings. This structure enables linear-time solutions for various string problems, including range queries about palindromes and enumerating palindromic-rich strings.

What Problem Does This Paper Address?

The paper tackles the challenge of efficiently managing palindromic information within a string that is being dynamically modified from both its front and back. Traditional eertrees are excellent for static strings, but adapting them to handle deque-like operations (push/pop from both ends) while maintaining performance for palindrome-related queries is complex. The authors introduce a new concept, "surfaces," which are specific palindromic substring occurrences that are crucial for enabling these efficient dynamic operations.

Methods

The core innovation is the double-ended eertree, an extension of the standard eertree. This structure supports four fundamental operations: push_back(c), push_front(c), pop_back(), and pop_front(). To achieve linear time complexity for these operations, the authors introduce the concept of surfaces. Surfaces are defined as palindromic substring occurrences that are neither prefixes nor suffixes of any other palindromic substring occurrences. These surfaces are key to efficiently updating the eertree structure. The paper also details two main approaches for implementing the double-ended eertree: an occurrence recording method and a more efficient surface recording method. The latter leverages the properties of surfaces to achieve better performance.

Datasets

Not discussed in the paper.

Key Insights and Ideas

  • Surfaces as a Key Concept: The paper identifies "surfaces" as a novel and crucial concept. These are palindromic substring occurrences that are "minimal" in the sense that they aren't extensions of other palindromes. This insight is fundamental to efficiently updating the eertree during dynamic string modifications.
  • Bridging Deques and Palindromes: The work effectively bridges the gap between dynamic string manipulation (deque operations) and palindrome analysis, a problem that was previously challenging to solve efficiently in a dynamic setting.
  • Linear Time for Dynamic Palindrome Management: The development of the double-ended eertree provides a linear-time solution for managing palindromic substrings in a dynamically changing string, which is a significant algorithmic advancement.
  • Unified Framework for Palindrome Queries: The double-ended eertree serves as a powerful tool for a range of palindrome-related range queries, offering improved performance over existing methods, especially in offline scenarios.

Key Results

  • Double-Ended Eertree: A new data structure that supports push_back, push_front, pop_back, and pop_front operations on a string in $O(\log \sigma)$ worst-case time and space per operation, where $\sigma$ is the alphabet size.
  • Surface Recording Method: An efficient method for maintaining the double-ended eertree, achieving $O(\log \sigma)$ time complexity for push operations and $O(1)$ for pop operations.
  • Applications:
    • Range Queries: Efficiently answers queries for counting distinct palindromic substrings, finding the longest palindromic substring, shortest unique palindromic substring, and shortest absent palindrome within any substring of the main string. Offline queries achieve $O(n\sqrt{q} \log \sigma)$ time and $O(n)$ space.
  • Enumerating Rich Strings: An algorithm for counting palindromic rich strings with a given word in $O(n\sigma + k\sigma^k)$ time, where $n$ is the length of the given word and $k$ is the additional length.

Limitations and Future Work

  • Space Complexity: While the paper presents an $O(\log \sigma)$ per-operation complexity, it notes that achieving linear space complexity in practice might require rebuilding the eertree periodically or releasing space for deleted nodes.
  • Further Exploration of Surfaces: The authors suggest that the concept of surfaces could be useful in other string processing problems.
  • Generalizations: Exploring dynamic maintenance of palindromes under split and concatenation operations, generalizing eertrees for palindromes in circles or trees, and developing quantum algorithms for palindromes are suggested future research directions.

Summary updated

Abstract

The palindromic tree (a.k.a. eertree) is a linear-size data structure that provides access to all palindromic substrings of a string. In this paper, we propose a generalized version of eertree, called double-ended eertree, which supports linear-time online double-ended queue operations on the stored string. At the heart of our construction, is a class of substrings, called surfaces, of independent interest. Namely, surfaces are neither prefixes nor suffixes of any other palindromic substrings and characterize the link structure of all palindromic substrings in the eertree. As an application, we develop a framework for range queries involving palindromes on strings, including counting distinct palindromic substrings, and finding the longest palindromic substring, shortest unique palindromic substring and shortest absent palindrome of any substring. In particular, offline queries only use linear space. Apart from range queries, we enumerate palindromic rich strings with a given word in linear time on the length of the given word.
BibTeX
@misc{wang2022double,
  author = {Qisheng Wang and Ming Yang and Xinrui Zhu},
  title = {{Double-Ended Palindromic Trees: A Linear-Time Data Structure and Its Applications}},
  year = {2022},
  eprint = {2210.02292},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2210.02292},
}

Loading related content...

Figure