文档简介
Instead of finding the longest commonsubsequence, let us try to determine thelength of the LCS. Then tracking back to find the LCS. Consider a1a2…am and b1b2…bn. Case 1: am=bn. The LCS must contain am,we have to find the LCS of a1a2…am-1 andb1b2…bn-1. Case 2: am≠bn. Wehave to find the LCS ofa1a2…am-1 and b1b2…bn, and a1a2…am andb b bb1b2…bn-1Let A = a1 a2 … am and B = b1 b2 … bn Let Li j denote the length of the longest i,g gcommon subsequence of a1 a2 … ai and b1 b2… bj. Li,j = Li-1,j-1 + 1 if ai=bjmax{ L L } a≠b i-1,j, i,j-1 if ai≠jL0,0 = L0,j = Li,0 = 0 for 1≤i≤m, 1≤j≤n.
评论
加载更多
推荐下载
查看更多
精选文集
推荐帖子