# 10/12/20141LCS.  Given two strings S 1 of length m and S 2 of length n over the same alphabeth. The Longest Common Substring problem is to find the longest.

## Presentation on theme: "10/12/20141LCS.  Given two strings S 1 of length m and S 2 of length n over the same alphabeth. The Longest Common Substring problem is to find the longest."— Presentation transcript:

10/12/20141LCS

 Given two strings S 1 of length m and S 2 of length n over the same alphabeth. The Longest Common Substring problem is to find the longest substring of S 1 that is also a substring of S 2.  A generalization is the k-common substring problem. Given the set of strings S={S 1,S 2,……………, S k }. where |S i |=n i. Σ n i =N. Find for each 2 ≤ k ≤ K, the longest string which occur as substring of all strings. 10/12/20142LCS

10/12/2014LCS3

10/12/2014LCS4

10/12/2014LCS5

10/12/2014LCS6 ABAB 00000 B 00101 A 01020 B 00203 A 00030 i j ABABAB Longest Common Substring

10/12/2014LCS7 a c c b b b c \$ # \$ # b c \$ # a b c # c \$

10/12/2014LCS8 Common Sub-Strings ‘a’ ‘b’ ‘c’ ‘ab’ ‘bc’ Longest Common Sub-String ‘ab’ ‘bc’

10/12/2014LCS9 LCS compares two strings and finds the longest run of characters that occurs in both of them. We can then declare the two documents as near duplicates if the ratio of the common substring length to the length of the documents exceeds some threshold. Consider the Example Below Selling a beautiful house in California. Buying a beautiful chip in California. The longest common substring is " in California." (it is 15 characters long, whereas " a beautiful " comes in second at 13 characters long). The first string is 40 characters long. So, you could assess how similar the strings are by taking the ratio: 15/40 = 0.375. Best part about this application is that user can decide the threshold level interactively Target Audience of this Application *Ideal for Universities which do not have access to turn it in. *Students who do not have access to turn it.

10/12/2014LCS10 Medical record linkage is becoming increasingly important as clinical data is distributed across independent sources. Two corresponding fields within a record are said to agree only if all characters match; otherwise the fields are considered as mismatches. LCS score for the names ‘TAMMY SHACKELFORD’ ‘TAMMIE SHACKLEFORD’ The total length of the common substrings is [5 (SHACK) + 4 (TAMM) + 4 (FORD)] = 13. The length of the shorter name string (ignoring white space) is 16, therefore the LCS score is (13÷16) = 0.8125

10/12/2014LCS11 ApproachWorst Case Time Complexity Brute ForceO(n^3) Dynamic ProgrammingO(m n) Suffix ArrayO(n log n) Suffix TreeO(n)

10/12/2014LCS12 ApproachTime Complexity Time(ms)Basic OperationsExecution Time (mille seconds) Brute Forcen^3129 Dynamic Programmingm*n68 Suffix Treen29 ApproachTime Complexity Time(ms)Basic OperationsExecution Time (mille seconds) Brute Forcen^3273 Dynamic Programmingm*n120 Suffix Treen60 Results were Measured on Intel Core i-7 2.00 GHZ processor 4GB Ram System

10/12/2014LCS13  In Dynamic programming following changes can be done to exiting algorithm to reduce the memory usage of an implementation :-  Keep only the last and current row of the Dynamic Programming table to save memory O(min(m, n)) instead of O(n m)).  Store only non-zero values in the rows. This can be done using hash tables instead of arrays. This is useful for large alphabets.  Exiting Ukkonen’s suffix-tree implementation of longest common substring problem can be modified using McCreight and Weiner to see marginal improvement in time and space complexities.  Hybrid algorithm's performance can be compared with exiting performance results and see if there is any significant change in time and space complexity using rolling hash and suffix arrays

10/12/2014LCS14 On–line construction of Su ﬃ x trees http://www.cs.helsinki.fi/u/ukkonen/SuffixT1withFigs.pdf http://www.cs.helsinki.fi/u/ukkonen/SuffixT1withFigs.pdf Longest common substring problem http://en.wikipedia.org/wiki/Longest_common_substring_problem#See_also Generalized suffix tree http://en.wikipedia.org/wiki/Generalized_suffix_tree Real World Performance of Approximate String Comparators for use in Patient Matching http://www.cs.mun.ca/~harold/Courses/Old/CS6772.F04/Diary/5604Grannis.pdf

10/12/2014LCS15

Download ppt "10/12/20141LCS.  Given two strings S 1 of length m and S 2 of length n over the same alphabeth. The Longest Common Substring problem is to find the longest."

Similar presentations