ALGORITHMES POUR LA BIO-INFORMATIQUE ET LA VISUALISATION COURS 2 Raluca Uricaru Chapter 32 of Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Naive string matcher Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Exercice Suppose that all characters in the pattern P are different. How do you accelerate the Naive string matcher to run in time O(n) on an n-character text T? Rabin – Karp matcher Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Exercices 1. Working modulo q = 11, how many spurious hits does the Rabin-Karp matcher encounter in text T = 3141592653589793 ? 2. How would you extend the Rabin-Karp method to the problem of searching a text string for the occurrences of the patterns in a given set of k patterns? Knuth-Morris-Pratt (KMP) matcher Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Exercice Compute the prefix function for the pattern ababbabbabbababbabb Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.