0
votes

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?

Here LCP array is between i and i-1 indexes.

Say we have two strings str=abcabc and str1=bc. I change str= str + '#' + str1.

My suffix array SA[]=[6,3,0,7,4,1,8,5,2]

And LCP array be=[0,0,3,0,2,2,0,1,1]

What can be a better algorithm to find them ?

1
You can easily answer that question yourself, by checking if it works. - Some programmer dude
@JoachimPileborg Actually I want to know better algorithm to find all longest common substrings with their indexes in a different vector/array - user3405426
In that case I don't think it's a question for SO, but better fitted on codereview.stackexchange.com instead. Also, if you want a better algorithm then you should probably actually state so in your question. - Some programmer dude

1 Answers

-1
votes

There is a good article on finding all common substrings efficiently, with examples in C. http://www.drdobbs.com/architecture-and-design/algorithm-alley/184404588