美文网首页动态规划
【动态规划】最长公共子序列问题(Longest common s

【动态规划】最长公共子序列问题(Longest common s

作者: a1cfe81e4f39 | 来源:发表于2016-11-17 17:25 被阅读0次

根据算法课总结。

最长公共子序列是一种衡量两个string相似度的方式。

子序列(subsequence)是包含在string里的序列,它不需要连续,可间断。

因为一个string 有2^N个子序列,所以如果用穷举法(brute force method),则需要O(2^N)次。

动态规划是可行的。

1. 这个问题有最优结构(optimal structure)。

2. 有重叠的子问题(overlapping subproblems)。

3. Θ(MN)

java 代码,两种方法。

重建LCS

performance

相关文章

网友评论

    本文标题:【动态规划】最长公共子序列问题(Longest common s

    本文链接:https://www.haomeiwen.com/subject/ykydpttx.html