分享到plurk 分享到twitter 分享到facebook

版本 a052ff5b6a4a8bfa550ab632925969b6be7a9d62

acm/course/LCS

Changes from a052ff5b6a4a8bfa550ab632925969b6be7a9d62 to 626fa16d9c9f9a834506e3d8801acfee17b0f8b7

Define<br/>
<ul> Find a sub-sequence of 2 given sequences in which the sub-sequence`s elements are appear in both original sequences.
     And the sub-sequence is as long as possible. </ul>
<ul> ex: 'aabbcc', 'abbccc' => 'abc'</ul>
<br/>
What do we want to know?
<ul> – The LCS of S1[1...i] and S2[1...j]. </ul>
<ul> – i.e. LCS[i][j] </ul><br/>

How can we get that?
<ul>– Find the previous number with longest LIS. </ul>
<ul>– LCS[i][j]:
 <ul>
     0                            , i=0 or j=0
     LCS[i-1][j-1]+1              , S1[i]=S2[j]
     max(LCS[i-1][j],LCS[i][j-1]) , S1[i]≠S2[j]
 </ul>
</ul><br/>
</ul>
<ul>
ex: 'CBABCABCC' , 'ABCABCBA' => ABCABC<br/>
 <img src="http://wiki.csie.ncku.edu.tw/acm/LCS-1.png" height="200" width="200"/>
 <img src="http://wiki.csie.ncku.edu.tw/acm/LCS-2.png" height="200" width="200"/>
 <img src="http://wiki.csie.ncku.edu.tw/acm/LCS-3.png" height="200" width="200"/>
 <img src="http://wiki.csie.ncku.edu.tw/acm/LCS-4.png" height="200" width="200"/>
</ul>