At Most N Palindromes

How many distinct palindromic substrings can a string of length nn have, and what does an Eertree cost?

A

Θ(nlog⁡n)\Theta(n \log n), which is why the palindromic tree has Θ(nlog⁡n)\Theta(n \log n) nodes and builds in Θ(nlog⁡n)\Theta(n \log n): the fail tree has depth Θ(log⁡n)\Theta(\log n).

B

At most nn, which is why the palindromic tree has O(n)O(n) nodes and builds in O(n)O(n): appending one character adds at most one new palindrome.

C

Θ(n2)\Theta(n^2), which is why the palindromic tree has Θ(n2)\Theta(n^2) nodes and builds in Θ(n2)\Theta(n^2): in aaa...a every substring is a palindrome.

D

Exactly 2n2n, which is why the palindromic tree has O(n)O(n) nodes and builds in O(n)O(n): appending one character adds one odd and one even palindrome.