2

Can we use suffix tree to count numbers of distinct subsequence (rather than substring)?

Definition: A subsequence of a string is a new string which is formed from the original string by deleting some of the characters without disturbing the relative positions of the remaining characters. (ie, "ACE" is a subsequence of "ABCDE" while "AEC" is not).

So if given a String S = "rabbbit", pattern of subsequence P = "rabbit", can we use suffix tree to find out the numbers of distinct subsequence of P in S?

It should return 3 from manual inspection.

I would really appreciate if someone is willing to make a good education on this topic by drawing a suffix tree of "rabbbit" and solve this problem.

Note - we could solve this problem with other techniques like DP but I am more interested in if we could use suffix tree to solve it. thanks!

Eric H.
  • 341
  • 2
  • 7
  • 18

0 Answers0