Lecture 21

Learning objectives

After this class, you should be able to:

  1. Define the string matching problem and the following terms: text, pattern, valid shift, invalid shift, empty string, concatenation of strings, prefix, suffix.
  2. Given a pattern and a text, apply the naive string matching algorithm to determine all occurrences of the pattern in the text.
  3. Prove simple properties of suffixes and prefixes, such as lemma 32.1, including new ones not discussed in class.
  4. Give reasons to justify the correctness of the naive algorithm, and derive its time complexities.
  5. Given a new algorithm for string matching, prove its correctness and derive its time complexity, or prove that it is incorrect.
  6. Given an algorithm for string matching, give examples to demonstrate worst-case and best-case time complexities.

Reading assignment

  1. CLR: Chapter 32, up to (and including) section 32.1.

Exercises and review questions


Last modified: 30 Jul 2004