How does LCP help in finding the number of occurrences of a pattern?

后端 未结 2 1309
醉酒成梦
醉酒成梦 2020-12-13 09:56

I have read that the Longest Common Prefix (LCP) could be used to find the number of occurrences of a pattern in a string.

Specifically, you just ne

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 10:36

    The Longest Common Prefix (LCP) is the Lowest Common Ancestor (LCA) in a suffix tree. Once you have the Lowest Common Ancestor, you can count the number of nodes that branch out from the LCA. This will give you the number of occurrences of a pattern in the suffix tree. This is the relationship between the LCP and LCA.

提交回复
热议问题