2

I am given two strings, $\overline{a},\overline{b}$ in a finite alphabet, $\Sigma$, and a positive integer $k$. I want to compute the $k$-th order contiguous string kernel, which is defined to be the sum $$\sum_{s\in\Sigma^k}n_s(\overline{a})n_s(\overline{b})$$ where $n_s(x)$ is equal to the number of occurrences of $s$ as a substring of $x$. I am trying to come up with an $O(k\ell_a\ell_b)$ algorithm for this, where $\ell_a,\ell_b$ are the lengths of $\overline{a},\overline{b}$, respectively.

I think the algorithm uses the fact that the substring must be present in both strings in order to actually affect the sum but I am unsure where to go from there in order to get such an algorithm. Any help or references to related sources would be greatly appreciated!

D.W.
  • 167,959
  • 22
  • 232
  • 500
Twis7ed
  • 161
  • 4

0 Answers0