A palindrome is a string that reads the same forwards and backwards: racecar, level, abba. Finding one is easy. Counting all distinct palindromic substrings in a long piece of text — without duplicates — turns out to be surprisingly subtle.
A string of length can have up to distinct palindromic substrings (one ending at each position, a result known since the early 2000s). Naively checking every substring is at best; storing them all without a compact representation wastes enormous space.
In 2013–2015, Mikhail Rubinchik and Arseny M. Shur introduced the eertree (also called the palindromic tree): a single data structure that represents every distinct palindromic substring of a text, built online — one character at a time — in time and space. The name is a portmanteau of eertree because the structure looks like a tree and "eert" is "tree" backwards — a nod to its palindromic soul.
Comments
Loading comments...