1 / 21

CHAPTER 2

CHAPTER 2. The Basic Concepts of Algorithms. The Minimal Spanning Tree Problem. Spanning tree Prim ’ s Algorithm Kruskal ’ s Algorithm. The Longest Common Subsequence Problem. S1 : ABDDRGTY S2 : CDEDRGRT DRT DRGT DDRGT. The Dynamic Programming Strategy.

duy
Download Presentation

CHAPTER 2

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. CHAPTER 2 The Basic Concepts of Algorithms

  2. The Minimal Spanning Tree Problem • Spanning tree • Prim’s Algorithm • Kruskal’s Algorithm

  3. The Longest Common Subsequence Problem • S1 : ABDDRGTY • S2 : CDEDRGRT DRT DRGT DDRGT

  4. The Dynamic Programming Strategy • If we go through a vertex X, we should find a shortest route from X to T.

  5. Application of the Dynamic Programming Strategy to Solve the LCS problem • LCS(i,j)=LCS(i-1,j-1)+1 if max{LCS(i-1,j),LCS(i,j-1)} if LCS(0,0)=LCS(1,0)=LCS(0,1)=0

  6. The Time-Complexity of Algorithms • Find a LCS : best case: O( ) average Case: O( ) worst case: O( ) Quicksort : best case: O( n log n ) average Case: O( n log n ) worst case: O( )

  7. The 2-Dimensional Maxima Finding Problem and the Divide and Conquer Strategy • A point( ) is said to dominate another point( ) if , .If a point is not dominated by any point ,is called a maxima.

  8. The Selection Problem and the Prune and Search Strategy • Give a set S of n numbers,there is a number p which divides S into three subsets S1,S2and S3. case1:the size of S is greater than k.Kth smallest of S must be located in S1 ,prune away S2 and S3. case2:the condition of Case1 is not valid.But the size of S1 and S2 is greater than k.the kth smallest number of S must be equal to p. case3:none of the conditions of case1 and case2 is valid.In this case,the kth smallest number of S must be located in S3 and we can prune away S1 and S2

  9. The NP-Complete Problems • NP problems are all decision problems • Nearly all of the decision problems are NP problems.

  10. CHAPTER 3 String Matching

  11. 3.1 Basic Terminologies of Strings • |S|=sting S 的長度 “AGCTTGATT” • Substring, “GCTT”“TTG” • Subsequences, “ACT”“GTT” • Prefix of string “AGCT”“AG” • Suffix of string “GATT”“TT”

  12. The KMP Algorithm • Knuth, Morris, Pratt in 1977 • Case1:the fist symbol of P dose not appear again in P. • Case2:the first symbol of P appears again in P.

  13. Case3:not only the first symbol of P appears in P,prefixes of P appear in P twice.

  14. If a mismatch occurs when is compared with ,then align with if j!=1 and align with if j=1.

  15. The Boyer-Moore Algorithm • Boyer,Moore in 1977,more efficient in practice than KMP • Bad Character Rule:Align with ,where j’ is the rightmost position of in P. • Good Suffix rule 1:Align with , where j’ is the largest position such that is a suffix of and

  16. Good suffix Rule 2:Align with ,where j’ is the largest position such that is a suffix of • Function G: (a) be the largest k such that is a suffix of and ,0 if there is no such k. (b) be the largest k such that is a suffix of ; 0 if there is no such k. (c). G(j)={m - max{ , }}

  17. Function f’:

  18. The Boyer-Moore algorithm for exact for exact matching.

  19. s=14 > n – m + 1 = 24 – 12 + 1 = 13

  20. Suffix Trees and suffix Arrays • Suffixes suffix tree

  21. Approximate String Matching • Case 1: E(i,j)=E(i-1,j-1) • Csse 2: E(i,j)={E(i-1,j),E(i,j-1)}+1

More Related