13.07.2015 Views

Finding All Approximate Palindromes

Finding All Approximate Palindromes

Finding All Approximate Palindromes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The 25th Workshop on Combinatorial Mathematics and Computation Theoryfocus on algorithms to find the edit distancebetween two strings, and many of them [1, 3, 4, 6,7, 10, 11, 12, 14, 15, and 16] use the followingrule: Consider the two strings A A 1A2andB B 1B 2, if A2 B2and ED ( A1 , B1) k , thenED ( A,B) k .There are two approaches to solve theapproximate string matching problem. The firstapproach [12, 2, 10, 11 and 15] is a local approachwhich computes ED ( P,S)where S is asubstring of T starting from each location i .That is, for every possible position i , we testwhether there exists a substring S of Tstarting from this location such that ED( P,S) k .Another approach [16], named Approach 2, is aglobal approach which can solve the problem inmO( nk ) time-complexity where w is the word wsize. We shall use the technique in [16] to solvethe problem.In the above, we only talked about one case.In the following, we give the precise definition ofS1and S 2for all cases.Case 1: We find even approximate palindromes. If1 i n2, let S1be T ( 1, i)and S2beT ( i 1, min{2i k,n}); otherwise, let S1beT (max{ 2i n k 1,1},i)and S2beT ( i 2, n).Case 2: We find odd approximate palindromes.If 1 i n2 , let S 1be T ( 1, i)and S 2beT ( i 2,min{2i k 1,n}); otherwise, let S 1beT (max{ 2i n k 2,1}, i)and S2beT ( i 2, n).Essentially, for each location i in T , wecompute the edit distance between S 1and S 2.Given two strings S 1 p 1p 2 p m',S t t tand k , we define2 1 2 n'M k1,if ED(S1(1, j),S2(1, i)) k( i,j) ,0,otherwise.where 0 i n'and 0 j m'.We now use dynamic approach to find M k ( i,j).Let M k ( i,j)I, M k ( i,j)Dand M k ( i,j)Sdenotethe M k( i,j)related to insertion, deletion andsubstitution respectively, wherek 11, if t p , M ( i 1,j) 1i jkkM ( i,j) or ti pjand M ( i 1,j 1) 1 0, otherwise.MI,kDandMkSk 11, if t p , M ( i,j 1) 1i jk( i,j) or ti pjand M ( i 1,j 1) 1 0, otherwise.k1, if t p and Mi j( i,j) or ti pjand M 0, otherwise.1k( i 1,j 1) 1( i 1,j 1) 1After every M k ( i,j)I, M k ( i,j)DandM k S( i,j)are found, we can determine M k( i,j)by M k ( i,j)= M k I( i,j)or M k D( i,j)or ( i,j)M k Swhere “or” is the “logical or” operation .Our algorithm is presented in the following:Input: A string T t1t2... tn.and k.Output: <strong>All</strong> occurrences of approximate palindromesof T with error k ' .for i=1 to n dofor 0 k' k dofor 0 i' n'and 0 j' m'dok 'M(0, j') 1, if 0 j' k'k ' k 'M ( i', j') M( i',0) 1, if 0 i' k'0 otherwise'M k '( i', j') M k '( i', j') or ( i', j')IM k D'or M k S( i', j') ;end forend forend for2-243-

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!