Popular recipes tagged "lcs"http://code.activestate.com/recipes/tags/lcs/2015-06-01T08:08:11-07:00ActiveState Code RecipesLongest common subsequence of 3+ strings (Python)
2015-06-01T08:08:11-07:00Alister Cordinerhttp://code.activestate.com/recipes/users/4174503/http://code.activestate.com/recipes/579065-longest-common-subsequence-of-3-strings/
<p style="color: grey">
Python
recipe 579065
by <a href="/recipes/users/4174503/">Alister Cordiner</a>
(<a href="/recipes/tags/diff/">diff</a>, <a href="/recipes/tags/lcs/">lcs</a>).
</p>
<p>Script to find the longest common subsequence (LCS) of 3+ strings using dynamic programming.</p>
Longest common subsequence problem solver (Python)
2009-08-06T06:36:56-07:00Shao-chuan Wanghttp://code.activestate.com/recipes/users/4168519/http://code.activestate.com/recipes/576869-longest-common-subsequence-problem-solver/
<p style="color: grey">
Python
recipe 576869
by <a href="/recipes/users/4168519/">Shao-chuan Wang</a>
(<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/lcs/">lcs</a>, <a href="/recipes/tags/longest_common_subsequence/">longest_common_subsequence</a>).
Revision 2.
</p>
<p>Longest common subsequence problem is a good example of dynamic programming, and also has its significance in biological applications.</p>
<p>For more information about LCS, please see:
<a href="http://en.wikipedia.org/wiki/Longest_common_subsequence_problem" rel="nofollow">http://en.wikipedia.org/wiki/Longest_common_subsequence_problem</a></p>
<p>Also, here, I use a 'cached' decorator to keep core algorithm neat.
You can see how great the decorator could be. :)</p>
<p>Also note that, this recipe is just a demonstration of LCS and the usage of a python decorator. However, the memory is not used very efficiently. If the problem is very large-scaled, it may lead to stack overflow or memory error. </p>
<p>So, do not use this recipe to deal with large-scaled problems. ;)</p>