Efficient LCS Algorithms: Optimized Hirschberg and Hunt-Szymanski Methods

speeding up hirschberg and hunt szymanski n.w
1 / 28
Embed
Share

Explore two efficient algorithms improving Hirschberg and Hunt-Szymanski methods for finding the longest common subsequence of two strings. These algorithms leverage bit-vector operations, demonstrating high practical efficiency.

  • LCS Algorithms
  • Hirschberg
  • Hunt-Szymanski
  • Bit-vector operations
  • String matching

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Speeding-up Hirschberg and Hunt-Szymanski LCS Algorithms Maxime Crochemore, Costas S. Iliopoulos, and Yoan J. Pinzon Fundamental Informaticae XX pp.1- 14(2003)

  2. Abstract Two algorithms are presented that solve the problem of recovering the longest common subsequence of two strings. The first algorithm is an improvement of Hirschberg's divide-and- conquer algorithm. The second algorithm is an improvement of Hunt-Szymanski algorithm based on an efficient computation of all dominant match points. These two algorithms use bit-vector operations and are shown to work very efficiently in practice.

  3. Basic Background x = ttatccg y = agcaact

  4. Basic Background x = ttatccg y = agcaact

  5. Basic Background x = ttatccg y = agcaact

  6. Basic Background x = ttatccg y = agcaact

  7. Basic Background x = ttatccg y = agcaact

  8. Speeding-up the Hirschberg Algorithm

  9. FindRow A = ABCD B = ACDE A 0 1 1 1 1 C 0 1 1 2 2 D 0 1 1 2 3 E 0 1 1 2 3 A C D E 0 0 0 0 0 A B C D A 0 0 0 0 0 A 0 1 C 0 1 D 0 1 E 0 1 0 0 A

  10. FindRow A = ABCD B = ACDE A 0 1 1 1 1 C 0 1 1 2 2 D 0 1 1 2 3 E 0 1 1 2 3 A 1 0 C 1 0 D 1 0 E 1 0 0 0 0 0 0 0 0 A B C D B A 1 1 C 1 1 D 1 1 E 1 1 0 0 B

  11. FindRow A = ABCD B = ACDE A 0 1 1 1 1 C 0 1 1 2 2 D 0 1 1 2 3 E 0 1 1 2 3 A 1 0 C 1 0 D 1 0 E 1 0 0 0 0 0 0 0 0 A B C D C A 1 1 C 1 2 D 1 2 E 1 2 0 0 C

  12. FindRow A = ABCD B = ACDE A 0 1 1 1 1 C 0 1 1 2 2 D 0 1 1 2 3 E 0 1 1 2 3 A 1 0 C 2 0 D 2 0 E 2 0 0 0 0 0 0 0 0 A B C D D A 1 1 C 2 2 D 2 3 E 2 3 0 0 D

  13. BV-FindRow Bit-Vector M A 1 0 0 0 B 0 0 0 0 C 0 0 1 0 D 0 0 0 1 E 0 0 0 0 L-metrix A B C D A 0 0 C 0 0 D 0 0 E 0 0 0 0 A Bit-Vector M A 0 1 1 1 B 1 1 1 1 C 1 1 0 1 D 1 1 1 0 E 1 1 1 1 A B C D 0 0 0 A 0 1 C 0 1 D 0 1 E 0 1 A V [0] = 1 V [1] = (V [0] + (V [0] & M[A])) | (V [0] & M [A]) = (1 + 1 & 1) | (1 & 0) = 0, carry = 1, L[1] = L[0] + 1

  14. BV-FindRow Bit-Vector M A 1 0 0 0 B 0 0 0 0 C 0 0 1 0 D 0 0 0 1 E 0 0 0 0 L-metrix A B C D A 0 1 C 0 1 D 0 1 E 0 1 0 0 B Bit-Vector M A 0 1 1 1 B 1 1 1 1 C 1 1 0 1 D 1 1 1 0 E 1 1 1 1 A B C D 0 0 0 A 1 1 C 1 1 D 1 1 E 1 1 B V [0] = 1 V [1] = (V [0] + (V [0] & M[B])) | (V [0] & M [B]) = (1 + 1 & 0) | (1 & 1) = 1, carry = 0, L[1] = L[0]

  15. BV-FindRow Bit-Vector M A 1 0 0 0 B 0 0 0 0 C 0 0 1 0 D 0 0 0 1 E 0 0 0 0 L-metrix A B C D A 0 1 C 0 1 D 0 1 E 0 1 0 0 C Bit-Vector M A 0 1 1 1 B 1 1 1 1 C 1 1 0 1 D 1 1 1 0 E 1 1 1 1 A B C D 0 0 0 A 1 1 C 1 2 D 1 2 E 1 2 C V [0] = 1 V [1] = (V [0] + (V [0] & M[C])) | (V [0] & M [C]) = (1 + 1 & 1) | (1 & 0) = 1, carry = 1, L[1] = L[0] + 1

  16. BV-FindRow Bit-Vector M A 1 0 0 0 B 0 0 0 0 C 0 0 1 0 D 0 0 0 1 E 0 0 0 0 L-metrix A B C D A 0 1 C 0 1 D 0 1 E 0 1 0 0 D Bit-Vector M A 0 1 1 1 B 1 1 1 1 C 1 1 0 1 D 1 1 1 0 E 1 1 1 1 A B C D 0 0 0 A 1 1 C 2 2 D 2 3 E 2 3 D V [0] = 1 V [1] = (V [0] + (V [0] & M[D])) | (V [0] & M [D]) = (1 + 1 & 1) | (1 & 0) = 1, carry = 1, L[1] = L[0] + 1

  17. Hirschbergs Algorithm H(4, 4, ABCD , ACDE ) BV-FindRow(2, 4, AB , ACDE ) BV-FindRow(2, 4, DC , EDCA ) A 0 1 1 C 0 1 1 D 0 1 1 E 0 1 1 E 0 0 0 D 0 1 1 C 0 1 2 A 0 1 2 0 0 0 0 0 0 A B D C

  18. Hirschbergs Algorithm A = ABCD B = ACDE A 1 1 C 1 1 D 1 1 E 1 1 E 0 0 D 1 1 C 1 2 A 1 2 0 0 0 0 B C J = 0, 0 + 2 = 2 J = 1, 1 + 2 = 3 J = 2, 1 + 1 = 2 J = 3, 1 + 0 = 1 J = 4, 1 + 0 = 1 H(2, 1, AB , A ) H(2, 3, CD , CDE )

  19. Hirschbergs Algorithm H(2, 3, CD , CDE ) H(2, 1, AB , A ) BV-FindRow(1, 3, C , CDE ) BV-FindRow(1, 1, A , A ) A 0 1 C 0 1 D 0 1 E 0 1 0 0 0 0 A C BV-FindRow(1, 3, D , EDC ) BV-FindRow(1, 1, B , A ) A 0 0 E 0 0 D 0 1 C 0 1 0 0 0 0 B D

  20. Hirschbergs Algorithm A 0 1 C 0 1 D 0 1 E 0 1 0 0 0 0 A C A 0 0 E 0 0 D 0 1 C 0 1 0 0 0 0 B D J = 0, 0 + 1 = 1 J = 1, 1 + 1 = 2 J = 2, 1 + 0 = 0 J = 3, 1 + 0 = 1 H(1, 1, C , C ) => C H(1, 2, D , DE ) => D J = 0, 0 + 0 = 0 J = 1, 1 + 0 = 1 H(1, 1, A , A ) => A H(1, 0, B , null) = >null LCS : ACD

  21. Timing Curves for the H, and BV-H Algorithms

  22. Speeding-up the Hunt-Szymanski Algorithm Dominant Match Point = ? ? 1^? ? & ? [? 1]

  23. Speeding-up the Hunt-Szymanski Algorithm A = ABCD B = ACDE Dominant Match Point = ? ? 1^? ? & ? [? 1] Bit-Vector V 0 1 1 1 1 A C D E A B C D THRESH 0 0 1 2 3 4

  24. Speeding-up the Hunt-Szymanski Algorithm A = ABCD B = ACDE Dominant Match Point = ? ? 1^? ? & ? [? 1] Bit-Vector V 0 1 1 1 1 A 0 1 1 1 C D E A B C D THRESH 0 0 1 1 2 3 4

  25. Speeding-up the Hunt-Szymanski Algorithm A = ABCD B = ACDE Dominant Match Point = ? ? 1^? ? & ? [? 1] Bit-Vector V 0 1 1 1 1 A 0 1 1 1 C 0 1 0 1 D E A B C D THRESH 0 0 1 1 2 2 3 4

  26. Speeding-up the Hunt-Szymanski Algorithm A = ABCD B = ACDE Dominant Match Point = ? ? 1^? ? & ? [? 1] Bit-Vector V 0 1 1 1 1 A 0 1 1 1 C 0 1 0 1 D 0 1 0 0 E A B C D THRESH 0 0 1 1 2 2 3 3 4

  27. Speeding-up the Hunt-Szymanski Algorithm A = ABCD B = ACDE Dominant Match Point = ? ? 1^? ? & ? [? 1] Bit-Vector V 0 1 1 1 1 A 0 1 1 1 C 0 1 0 1 D 0 1 0 0 E 0 1 0 0 A B C D THRESH 0 0 1 1 2 2 3 3 4 LCS = ACD

  28. Timing Curves for the BV-H and BV- HS Algorithms

Related


More Related Content