TWISTED Longest common subsequence

I was wondering about a special case of the Longest Common Subsequence problem http://en.wikipedia.org/wiki/Longest_common_subsequence_problem What if we have two strings of n symbols and its guaranteed that both of them have exactly 1 symbol and every symbol from the first n symbols of an alphabet. How can the normal algorithm be improved?

Answers


You're asking for the longest common subsequence between permutations. There is an improvement over the dynamic programming one you linked called the Robinson-Schensted-Knuth algorithm, and it runs in time O(n lg n). There's a reasonably simple example of how it works in Lectures 7 & 8 of this course, and a much more complete but involved explanation here.


Need Your Help

click event not firing in backbone for iOS

javascript jquery-mobile cordova backbone.js requirejs

i have this project bundled with backbone,require.js underscore,jquerymobile into cordova or phonegap to deploy in iOS. but the click event is not working. i have this.

What to pass to UserType, BlobType.setPreparedStatement session parameter

java hibernate

http://blog.xebia.com/2009/11/09/understanding-and-writing-hibernate-user-types/