1 / 92

Permuted Scaled Matching

Permuted Scaled Matching. Ayelet Butman Noa Lewenstein Ian Munro. Scale d matching. Input: Text T=t 1 ,…,t n Pattern P=p 1 ,…,p m Scaling: P [ i ] =p 1 …p 1 p 2 …p 2 … p m …p m Output: All text-locations j where  i s.t. p [ i ] matches at j. . i. i. i. Scaled matching.

edison
Download Presentation

Permuted Scaled Matching

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Permuted Scaled Matching AyeletButman Noa Lewenstein Ian Munro

  2. Scaled matching Input: Text T=t1,…,tn Pattern P=p1,…,pm Scaling: P[i]=p1…p1p2…p2 … pm…pm Output: All text-locations j where  is.t. p[i] matches at j. i i i

  3. Scaled matching c b a a a c c a a a b b a a b a a b b b c c a c a b b

  4. Permutation matching Input: Text T=t1,…,tn Pattern P=p1,…,pm Permutation (of pattern): pπ(1)pπ(2)…pπ(m) where π is a permutation on [m]. Output: All text-locations j where a pattern permutation occurs.

  5. Permutation matching b c b a a b a a c b b a b b a a c b c a b b

  6. Permutation matching b a b a c b a a c b b a b b a a c b c a b b

  7. Permutation matching • Easy to solve in O(n) time (linear size alphabets). • The pattern matching version of Jumbled Indexing.

  8. Scaled permutation matching • Match: First Permutation and then Scaling.

  9. Scaled permutation matching c b a a c b b c a a a a a a b c c a b a b b a c a b b

  10. Scaled permutation matching • Match: First Permutation and then Scaling. • B-Eres-Landau[04]: Scaled Permutation Matching in O(n) time. • Open: Can one do the reverse efficiently, i.e. scaling and then permutation. • Hard ? How can we solve? First - Naïve algorithm

  11. Permuted scaled matching Input: Text T=t1,…,tn Pattern P=p1,…,pm Output: All text-locations j where exist permuted scaled matching

  12. Permuted scaled matching c b a a a c c a a a b b a a b b a b b c a a c c a b b

  13. Naïve algorithm P= c a a b T= c a b a a c b a c c a a b

  14. Naïve algorithm P= c a a b k=1 T= c a b a a c b a c c a a b

  15. Naïve algorithm P= c a a b k=2 T= c a b a a c b a c c a a b

  16. Naïve algorithm • Construct a table R of size (n+1)×|Σ| such that R(i,j)=#σj(T[0, i]) for i ≥ 0 and R(−1, j) = 0. • For every 0 ≤ i < j ≤ n−1 such that j −i+ 1 = km for some natural number k ≥ 1 do: • Let r(l) =( R(j,l)−R(i−1,l))/#σl(P). • if r(l) = k for each l, 0 ≤ l ≤ |Σ| − 1, then announce that i is a k-scaled appearance.

  17. Naïve algorithm P= c a a b T= c a b a a c b a c c a a b

  18. Naïve algorithm T= c a b a a c b a c c a a b

  19. Naïve algorithm T= c a b a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12

  20. Naïve algorithm T= c a b a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a b c

  21. Naïve algorithm T= c a b a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 b 0 c 0

  22. Naïve algorithm T= c a b a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 b 0 0 c 0 1

  23. Naïve algorithm T= c a b a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 1 b 0 0 0 c 0 1 1

  24. Naïve algorithm T= c a b a a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 1 1 b 0 0 0 1 1 c 0 1 1 1

  25. Naïve algorithm T= c a b a a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 1 1 2 b 0 0 0 1 1 1 c 0 1 1 1 1

  26. Naïve algorithm T= c a b a a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 1 1 2 3 3 3 4 4 4 5 6 6 b 0 0 0 1 1 1 1 1 2 2 2 2 2 2 3 c 0 1 1 1 1 1 2 2 2 3 4 4 4 4

  27. Naïve algorithm P= c a a b T= c a b a a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 1 1 2 3 3 3 4 4 4 5 6 6 b 0 0 0 1 1 1 1 1 2 2 2 2 2 2 3 c 0 1 1 1 1 1 2 2 2 3 4 4 4 4

  28. Naïve algorithm P= c a a b K= 1 T= c a b a a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 1 1 2 3 3 3 4 4 4 5 6 6 b 0 0 0 1 1 1 1 1 2 2 2 2 2 2 3 c 0 1 1 1 1 1 2 2 2 3 4 4 4 4

  29. Naïve algorithm P= c a a b K= 1 #a=2 #b=#c=1 T= c a b a a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 1 1 2 3 3 3 4 4 4 5 6 6 b 0 0 0 1 1 1 1 1 2 2 2 2 2 2 3 c 0 1 1 1 1 1 2 2 2 3 4 4 4 4

  30. Naïve algorithm P= c a a b K= 1 #a=2 #b=#c=1 T= c a b a a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 1 1 2 3 3 3 4 4 4 5 6 6 b 0 0 0 1 1 1 1 1 2 2 2 2 2 2 3 c 0 1 1 1 1 1 2 2 2 3 4 4 4 4

  31. Naïve algorithm P= c a a b K= 1 #a=2 #b=#c=1 T= c a b a a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 1 1 2 3 3 3 4 4 4 5 6 6 b 0 0 0 1 1 1 1 1 2 2 2 2 2 2 3 c 0 1 1 1 1 1 2 2 2 3 4 4 4 4

  32. Naïve algorithm P= c a a b K= 1 #a=2 #b=#c=1 = = 1 = = 1 = = 1 T= c a b a a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 1 1 2 3 3 3 4 4 4 5 6 6 b 0 0 0 1 1 1 1 1 2 2 2 2 2 2 3 c 0 1 1 1 1 1 2 2 2 3 4 4 4 4

  33. Naïve algorithm P= c a a b K= 1 #a=2 #b=#c=1 = = 1 = 0 T= c a b a a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 1 1 2 3 3 3 4 4 4 5 6 6 b 0 0 0 1 1 1 1 1 2 2 2 2 2 2 3 c 0 1 1 1 1 1 2 2 2 3 4 4 4 4

  34. Naïve algorithm P= c a a b K= 2 #a=2 #b=#c=1 = = = 2 = = 2 T= c a b a a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 1 1 2 3 3 3 4 4 4 5 6 6 b 0 0 0 1 1 1 1 1 2 2 2 2 2 2 3 c 0 1 1 1 1 1 2 2 2 3 4 4 4 4

  35. Naïve algorithm P= c a a b K= 2 #a=2 #b=#c=1 = = = 2 = = 2 T= c a b a a a c b a c c a a b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 1 1 2 3 3 3 4 4 4 5 6 6 b 0 0 0 1 1 1 1 1 2 2 2 2 2 2 3 c 0 1 1 1 1 1 2 2 2 3 4 4 4 4

  36. Naïve algorithm P= c a a b K= 2 #a=2 #b=#c=1 T= c a b a a a c b a c c a a b = = = 2 = 2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 1 1 2 3 3 3 4 4 4 5 6 6 b 0 0 0 1 1 1 1 1 2 2 2 2 2 2 3 c 0 1 1 1 1 1 2 2 2 3 4 4 4 4

  37. Naïve algorithm The running time is where .

  38. Better? Properties • Mod-Equivalency: i and j are Mod-Equivalent if for every character σ (with frequency c in P): #σ in T[0,i] mod c = #σ in T[0,j] mod c • Equal-Quotients: i and j have equal-quotients for char’s a & b if:

  39. Mod-equivalent • Mod-Equivalency: i and j are Mod-Equivalent if for every character σ (with frequency c in P): #σ in T[0,i] mod c = #σ in T[0,j] mod c

  40. Mod-equivalent P= c a a b #a=2 #b=#c=1 T= c c b a a a c b a c c b c b -1 0 1 2 3 4 5 6 7. 8 9 10 11 12 a 0 0 0 0 1 2 2 2 3 3 3 3 3 3 b 0 0 0 1 1 1 1 1 2 2 2 2 3 3 4 c 0 1 2 2 2 2 3 3 3 4 5 5 6 6

  41. Mod-equivalent P= c a a b #a=2 #b=#c=1 T= c c b a a a c b a c c b c b 3 11 a 1 3 b 1 3 c 2 6

  42. Mod-equivalent P= c a a b #a=2 T= c c b a a a c b a c c b c b 3 11 a a 1 3 b 1 3 c 2 6

  43. Mod-equivalent P= c a a b #a=2 T= c c b a a a c b a c c b c b 3 11 a a 1 3 b 1 3 c 2 6

  44. Mod-equivalent P= c a a b #a=2 T= c c b a a a c b a c c b c b 3 11 a 1 3 b 1 3 c 2 6

  45. Mod-equivalent P= c a a b #b=1 T= c c b a a a c b a c c b c b 3 11 a 1 3 b 1 3 c 2 6

  46. Mod-equivalent P= c a a b #c=1 T= c c b a a a c b a c c b c b 3 11 a 1 3 b 1 3 c 2 6

  47. Mod-equivalent P= c a a b T= c c b a a a c b a c c b c b 3 11 a 1 3 b 1 3 c 2 6

  48. Mod-equivalent P= c a a b #a=2 T= c c b a a a c b a c c b c b -1 0 1 2 3 4 5 6 7 8 9 10 11 12 a 0 0 0 0 1 2 2 2 3 3 3 3 3 3 b 0 0 0 1 1 1 1 1 2 2 2 2 3 3 4 c 0 1 2 2 2 2 3 3 3 4 5 5 4 4

  49. Mod-equivalent P= c a a b #a=2 T= c c b a a a c b a c c b c b 2 10 a 0 3 b 1 1 3 c 2 5

  50. Mod-equivalent P= c a a b #a=2 T= c c b a a a c b a c c b c b 2 10 a 0 3 b 1 1 3 c 2 5

More Related