← Algorithm Design learning path
Algorithm Design · Module 7 of 10

String algorithms

Search and process text efficiently.

📖 Key ideas

  1. Naive pattern search is O(nm).
  2. KMP uses a prefix table for O(n + m) search.
  3. Rabin-Karp uses rolling hashes.
  4. Tries store strings for fast prefix lookups.
  5. Applications: search engines, DNA analysis, autocomplete.
💡 Real-life example: KMP is a reader who remembers what already matched, so never rereads the same letters.
Pattern matchingFinding a pattern in text
KMPKnuth-Morris-Pratt algorithm
Rolling hashHash updated as window slides
TriePrefix tree for strings