Longest Common Subsequence
Version Control
Written by Flavio Adalberto Kubota   

This week I've implemented an algorithm to show difference between two texts.
I've implement the LCS(Longest Common Sequence) algotithm. The Longest Common Sequence consist is finding the longest subsequence common to all sequences in a set of sequences. It is a NP-Hard problem but can be solved in psedo-polynomial time using dynamic programming.
But what LCS algorithm can be used on diff problem?
The best diff result is the set with less common sequence between two sets. And, LCS can find the longest common subsequence. With LCS result, we can compare to two input sets and check what was add and what was removed, finding a solution. But this last comparison is not necessary, using the matrix built with dynamic programming, it is possible to find the the diff solution.
There's an optimization for my code, but I'll do it later. First, I need to make thinks work.
I have implemented these functions separately. Now I will integrate to Joomla!


 

 

Show other articles of this author

35 Votes

1 Comment

Feed
  1. Flavio, looks pretty cool stuff you're working...will checkout the project repository and take a look soon. Thanks for the blog, and keep up the good work!

Add Comment


    • >:o
    • :-[
    • :'(
    • :-(
    • :-D
    • :-*
    • :-)
    • :P
    • :\
    • 8-)
    • ;-)



    Click to get a new image.