Skip to content

Algo: String

Rishav Ray edited this page May 16, 2025 · 1 revision
  • A string algorithm is a one that deals with answering questions concerning strings.

  • There are 4 significant string algorithms: Robin-Karp, Huffman coding, Boyer-Moore, & Knuth–Morris–Pratt.

Robin-Karp

  • Robin-Karp is an algorithm used to find occurrences of a substrings in a given string. It relies on a rolling hash function, which is essentially a hash-function applied to each substring of the string, and whenever the value results in the same value as that of the target-substring, the characters of the substring are checked; if the characters of the substring match, then an occurrence has been found.

Huffman coding

  • Huffman coding is a lossless string-data compression algorithm that assigns either fixed or variable length codes to characters based on their frequency of occurrence in the string.

Boyer-Moore

  • Boyer-Moore is an algorithm used to search for a substring inside a string. It’s smarter than checking every position one by one— it skips ahead using clever rules, specifically the Bad Character Rule and the Good Suffix Rule.

Knuth–Morris–Pratt

  • Knuth–Morris–Pratt is an algorithm used to find occurrences of a substrings in a given string. This algorithm identifies repeated substrings and then uses this information to efficiently skip comparisons during the search.

Clone this wiki locally