简体   繁体   English

查找所有最长的公共子串

[英]Finding All longest common substring

I was trying to find ALL longest common substrings between two strings 我试图找到两个字符串之间的所有最长的公共子字符串

Supposing that i had computed Suffix array and LCP array correctly as SA[] and LCP[] Is my logic correct or am i missing something? 假设我已经计算后缀阵列的LCP阵列正确的SA []和LCP []是我的逻辑正确的还是我失去了一些东西?

Here LCP array is between i and i-1 indexes. 这里的LCP数组在i和i-1索引之间。

Say we have two strings str=abcabc and str1=bc. 假设我们有两个字符串str = abcabc和str1 = bc。 I change str= str + '#' + str1. 我更改了str = str +'#'+ str1。

My suffix array SA[]=[6,3,0,7,4,1,8,5,2] 我的后缀数组SA [] = [6,3,0,7,4,1,8,5,2]

And LCP array be=[0,0,3,0,2,2,0,1,1] 并且LCP数组be = [0,0,3,0,2,2,0,1,1]

What can be a better algorithm to find them ? 有什么更好的算法可以找到它们?

有一篇很好的文章介绍了如何有效地查找所有常见子字符串,并在C中提供了示例。http://www.drdobbs.com/architecture-and-design/algorithm-alley/184404588

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM