Algorithm to find common substring across N strings

前端 未结 2 833
小鲜肉
小鲜肉 2020-12-06 07:24

I\'m familiar with LCS algorithms for 2 strings. Looking for suggestions for finding common substrings in 2..N strings. There may be multiple common substrings in each pair.

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-06 07:54

    SUffix trees are the answer unless you have really large strings where memory becomes a problem. Expect 10~30 bytes of memory usage per character in the string for a good implementation. There are a couple of open-source implementations too, which make your job easier.

    There are other, more succint algorithms too, but they are harder to implement (look for "compressed suffix trees").

提交回复
热议问题