简体   繁体   English

使用Ukkonen算法的时间复杂度,Knuth–Morris–Pratt(KMP)和后缀树之间的差异。

[英]Difference between Knuth–Morris–Pratt (KMP) and suffix tree using Ukkonen's algorithm for time complexity.

Is it possible to find Longest Common Substring, Longest Palindromic Substring, Longest Repeated Substring, Searching All Patterns and Substring Check by both KMP and suffix tree using Ukkonen's algorithm? 是否可以使用Ukkonen算法通过KMP和后缀树找到最长的公共子串,最长的回文子串,最长的重复子串,搜索所有模式和子串检查? If yes then which one should I use since both algorithms have a linear-time complexity? 如果是,那么既然两种算法都具有线性时间复杂度,那我应该使用哪一种?

For finding the longest common substring, I would use Kadane's algorithm which has linear complexity. 为了找到最长的公共子串,我将使用具有线性复杂度的Kadane算法。 For the longest Palindromic Substring, the choice would be Manacher's algorithm which also has linear complexity. 对于最长的回文子串,可以选择Manacher算法,该算法也具有线性复杂度。 For repeated string and searching all patterns, yes the choice would boil down between KMP and Boyer-Moore. 对于重复的字符串并搜索所有模式,是的,选择将归结为KMP和Boyer-Moore。 As to which one, Boyer-Moore's matches the last character of the pattern instead of the first one with the assumption that if there's not match at the end no need to try to match at the beginning. 至于哪一个,Boyer-Moore匹配模式的最后一个字符而不是第一个字符,并假设如果结尾处不存在匹配,则无需在开头尝试匹配。 KMP searches for occurrences of a word W within a main text string S by employing the observation that when a mismatch occurs, thus bypassing re-examination of previously matched characters. KMP通过采用以下观察结果来搜索主文本字符串S中单词W的出现情况:发生不匹配,从而绕过了先前匹配字符的重新检查。 This makes KMP slightly better optimized for small sets like ACTGT. 这使得KMP可以更好地针对ACTGT等小型设备进行优化。

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

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