1 / 10

String matching algorithms

String matching algorithms. 97360986 鄭朝庭. String matching algorithms ( 字串比對演算法 )又稱 String searching algorithms ( 字串搜尋演算法 ),是 字串演算法 中的一類,用以試圖從較大的字串或文章中找到一個或多個字串的位置。. String Matching algorithm 其實在我們使用電腦時可以說是天天都會碰到,像是在 word 檔中搜尋以及在 google 收尋資料等等這都和 String Matching 息息相關,要如何快且有效率的比對字串可是門大學問。.

jovita
Télécharger la présentation

String matching algorithms

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. String matching algorithms 97360986 鄭朝庭

  2. String matching algorithms(字串比對演算法)又稱String searching algorithms(字串搜尋演算法),是字串演算法中的一類,用以試圖從較大的字串或文章中找到一個或多個字串的位置。

  3. String Matching algorithm其實在我們使用電腦時可以說是天天都會碰到,像是在word檔中搜尋以及在google收尋資料等等這都和String Matching息息相關,要如何快且有效率的比對字串可是門大學問。

  4. String Matching的演算法種類很多,以下為其搜尋字串時的比對順序分類有四種: 1.由左至右 2.由右至左 3.以特定格式 4.以任何順序

  5. String Matching 的大意是:有兩個字串 T 和 P ,找出 T 當中是否有一段字串正好是 P ,並找出位置。

  6. 最簡易的子字串搜尋法,是對於每一個字元開頭 Ti,判斷字串 T(i)T(i + 1)...T(i + n - 1),是否與欲搜尋之字串 P(0)P(1)...P(m - 1)相同。也就是把 P 對準 T 的各個位置,然後逐一比對各字元判斷一不一樣。然而,這樣的搜尋法時間複雜度為 O (n * m),當資料量極大時,將秏費相當多的時間。

  7. 因此,為加快子字串搜尋的速度,不斷改良後,出現了名為 Knuth-Morris-Pratt 的演算法,時間複雜度為 O(n+m) 。 • 此演算法的精髓在於,比對失敗時,能跳過不需再比對的部分,迅速找出下一次的比對點。

  8. String Matching:Knuth-Morris-Pratt Algorithm • Knuth-Morris-Pratt (克努斯-莫里斯-普拉特演算法)(常簡稱為「KMP演算法」)是在一個主「文字字串」T內尋找一個「詞」P的出現,透過採用一種簡單的觀察,在不匹配發生的時候這個詞自身包含足夠的資訊來確定下一個匹配將在哪裡開始,以此越過對以前匹配的字元的重新檢查。

  9. String Matching:Knuth-Morris-Pratt Algorithm • 演算法是由D.E Knuth和Pratt以及獨立地由J.H Morris在1977年發明的,但是三人聯合發表了它。

  10. 例子&相關網站 • http://www-igm.univ-mlv.fr/~lecroq/string/node8.html • http://www.csie.ntnu.edu.tw/~u91029/StringMatching.html

More Related