Skip to content
Back to categories

Pattern Matching

Algorithms that find patterns inside text or sequences.

Pattern matching algorithms locate exact or structured patterns in strings, arrays, and other ordered data.

Pattern MatchingO(nm)

Naive String Search

Finds a pattern by checking every possible starting position.

BeginnerFoundationFormula4 links
Pattern MatchingStringsLinear ScanClassic
Pattern MatchingO(n + m)

Knuth-Morris-Pratt

Finds pattern matches in text by using a prefix table to skip redundant comparisons.

IntermediateFoundationFormula17 links
Pattern MatchingStringsClassic
Pattern MatchingO(n)

Boyer-Moore

Searches text by comparing from the end of the pattern and making large skips.

IntermediateCoreFormula5 links
Pattern MatchingStringsHeuristic
Pattern MatchingO(n + m)

Rabin-Karp

Searches for a pattern by comparing rolling hash values.

IntermediateCoreFormula3 links
Pattern MatchingStringsRolling HashHashing
Pattern MatchingO(n + m + z)

Aho-Corasick

Finds many patterns in one text scan using an automaton.

AdvancedCoreFormula5 links
Pattern MatchingStringsAutomatonPrefix Tree
Pattern MatchingO(nm)

Levenshtein Distance

Measures how many insertions, deletions, or substitutions transform one string into another.

IntermediateCoreFormula11 links
Pattern MatchingStringsEdit DistanceDynamic Programming
Pattern MatchingO(nm)

Needleman-Wunsch

Globally aligns two sequences with dynamic programming.

IntermediateCoreFormula6 links
Pattern MatchingSequence AlignmentDynamic Programming
Pattern MatchingO(nm)

Regular Expression Matching

Matches text against patterns with operators such as choice, repetition, and character classes.

IntermediateCoreFormula3 links
Pattern MatchingStringsAutomaton
Pattern MatchingO(m log n)

Suffix Array Search

Finds substrings by binary searching a sorted array of suffixes.

AdvancedExtendedFormula5 links
Pattern MatchingStringsSuffix IndexSorted Data
Pattern MatchingO(n)

Z Algorithm

Computes how much each string suffix matches the string prefix.

IntermediateCoreFormula2 links
Pattern MatchingStringsClassic
Pattern MatchingO(n m)

Dynamic Time Warping

Measures similarity between sequences that may be stretched or shifted in time.

IntermediateCoreFormula3 links
Pattern MatchingDynamic ProgrammingSequence AlignmentTime Frequency
Pattern MatchingO(n m)

Longest Common Subsequence

Finds the longest sequence that appears in two inputs without requiring contiguous positions.

IntermediateCoreFormula4 links
Pattern MatchingStringsDynamic ProgrammingSequence Alignment
Pattern MatchingO(n)

Hamming Distance

Counts positions where two equal-length strings or vectors differ.

BeginnerCoreFormula3 links
Pattern MatchingStringsEdit Distance
Pattern MatchingO(n m)

Longest Common Substring

Finds the longest contiguous block shared by two strings.

IntermediateCoreFormula5 links
Pattern MatchingDynamic ProgrammingStringsSequence Alignment
Pattern MatchingO(n m)

Smith-Waterman

Finds the best local alignment between two sequences.

AdvancedCoreFormula4 links
Pattern MatchingSequence AlignmentDynamic ProgrammingEdit Distance
Pattern MatchingO(n + m)

Jaro-Winkler Distance

Scores string similarity with extra weight for shared prefixes.

IntermediateExtendedFormula3 links
Pattern MatchingStringsSimilarityEdit Distance
Pattern MatchingO(k n)

MinHash

Estimates set similarity by comparing compact hash signatures.

IntermediateCoreFormula4 links
Pattern MatchingHashingSimilarityProbabilistic Data Structure
Pattern MatchingO(k n)

Locality-Sensitive Hashing

Hashes similar items into the same buckets with higher probability than dissimilar items.

AdvancedCoreFormula3 links
Pattern MatchingHashingNearest NeighborSimilarity
Pattern MatchingO(n)

Suffix Automaton

Represents all substrings of a string in a compact deterministic automaton.

AdvancedExtendedFormula5 links
Pattern MatchingAutomatonStringsSuffix Index
Pattern MatchingO(n)

Bitap Algorithm

Searches for patterns by updating bit masks that represent matching prefixes.

AdvancedExtendedFormula2 links
Pattern MatchingStringsBit LevelSearch
Pattern MatchingO(n)

Wu-Manber

Searches for multiple patterns using block hashes and shift tables.

AdvancedExtendedFormula4 links
Pattern MatchingStringsMulti PatternHashing
Pattern MatchingO(n)

Myers Bit-Vector Algorithm

Myers Bit-Vector Algorithm finds exact or approximate matches in text or sequences.

IntermediateCoreNo formula1 links
Pattern MatchingStrings
Pattern MatchingO(n)

Ukkonen Edit Distance

Ukkonen Edit Distance scores how similar two strings, sets, or sequences are.

IntermediateCoreFormula1 links
Pattern MatchingStrings
Pattern MatchingO(n)

BK-Tree Search

BK-Tree Search finds exact or approximate matches in text or sequences.

IntermediateCoreNo formula3 links
Pattern MatchingStrings
Pattern MatchingO(n)

N-Gram Matching

N-Gram Matching finds exact or approximate matches in text or sequences.

IntermediateCoreNo formula3 links
Pattern MatchingStrings
Pattern MatchingO(n)

Cosine Similarity

Cosine Similarity scores how similar two strings, sets, or sequences are.

IntermediateCoreFormula1 links
Pattern MatchingStrings
Pattern MatchingO(n)

Jaccard Similarity

Jaccard Similarity scores how similar two strings, sets, or sequences are.

IntermediateCoreFormula1 links
Pattern MatchingStrings
Pattern MatchingO(n)

Dice Coefficient

Dice Coefficient scores how similar two strings, sets, or sequences are.

IntermediateCoreFormula1 links
Pattern MatchingStrings
Pattern MatchingO(n)

Soundex

Soundex finds exact or approximate matches in text or sequences.

IntermediateExtendedNo formula3 links
Pattern MatchingStrings
Pattern MatchingO(n)

Metaphone

Metaphone finds exact or approximate matches in text or sequences.

IntermediateExtendedNo formula3 links
Pattern MatchingStrings
Pattern MatchingO(n)

Damerau-Levenshtein Distance

Damerau-Levenshtein Distance scores how similar two strings, sets, or sequences are.

IntermediateCoreFormula2 links
Pattern MatchingStrings
Pattern MatchingO(n)

Optimal String Alignment

Optimal String Alignment aligns sequences with exact or approximate matches.

IntermediateExtendedFormula2 links
Pattern MatchingStrings
Pattern MatchingO(n)

Sellers Algorithm

Sellers Algorithm finds exact or approximate matches in text or sequences.

IntermediateExtendedNo formula2 links
Pattern MatchingStrings
Pattern MatchingO(n)

BLAST Seed-and-Extend

BLAST Seed-and-Extend aligns sequences with exact or approximate matches.

IntermediateSpecializedNo formula2 links
Pattern MatchingStrings
Pattern MatchingO(n)

FM-Index Search

FM-Index Search uses indexed text structure to speed pattern lookup.

IntermediateSpecializedFormula2 links
Pattern MatchingStrings
Pattern MatchingO(n)

Burrows-Wheeler Matching

Burrows-Wheeler Matching finds exact or approximate matches in text or sequences.

IntermediateExtendedNo formula2 links
Pattern MatchingStrings
Pattern MatchingO(n)

Karp-Miller-Rosenberg String Matching

Karp-Miller-Rosenberg String Matching finds exact or approximate matches in text or sequences.

IntermediateSpecializedNo formula2 links
Pattern MatchingStrings
Pattern MatchingO(n + m)

Shortest Common Superstring Greedy

Shortest Common Superstring Greedy handles shortest common superstring by repeatedly merging strings with the largest overlap.

IntermediateCoreNo formula4 links
Pattern MatchingStringsApproximation
Pattern MatchingO(n + m)

Overlap Graph Superstring

Overlap Graph Superstring addresses shortest common superstring by modeling string overlaps as a weighted graph path problem.

IntermediateExtendedNo formula2 links
Pattern MatchingStringsApproximationGraph
Pattern MatchingO(n + m)

Ukkonen Suffix Tree Construction

Ukkonen Suffix Tree Construction uses maintaining active points and suffix links during online construction for suffix tree construction.

IntermediateCoreNo formula5 links
Pattern MatchingStrings
Pattern MatchingO(n + m)

Suffix Automaton LCS

Finds a longest common substring by scanning one string through the suffix automaton of another.

IntermediateCoreFormula6 links
Pattern MatchingStrings
Pattern MatchingO(n + m)

Bit-Parallel Levenshtein

Bit-Parallel Levenshtein addresses edit distance by packing dynamic-programming columns into machine words.

IntermediateExtendedNo formula13 links
Pattern MatchingStringsMatchingApproximation
Pattern MatchingO(n + m)

Shift-And Algorithm

Uses bit masks to update all exact-match prefix states in parallel.

IntermediateCoreNo formula13 links
Pattern MatchingStringsMatching
Pattern MatchingO(n + m)

Shift-Or Algorithm

Performs exact string matching with bit masks that track unmatched pattern positions.

IntermediateCoreNo formula13 links
Pattern MatchingStringsMatching
Pattern MatchingO(n + m)

BNDM

BNDM addresses exact string matching by matching backward with a nondeterministic automaton encoded as bit masks.

IntermediateExtendedNo formula6 links
Pattern MatchingStringsMatching
Pattern MatchingO(n + m)

Commentz-Walter

Commentz-Walter addresses multiple string matching by combining Boyer-Moore style shifts with trie-based pattern matching.

AdvancedSpecializedNo formula2 links
Pattern MatchingStringsMatching
Pattern MatchingO(n + m)

Galil-Seiferas

Galil-Seiferas addresses exact string matching by using periodicity structure to guarantee linear-time matching with constant space.

AdvancedSpecializedNo formula2 links
Pattern MatchingStringsMatching
Pattern MatchingO(n + m)

Two-Way String Matching

Searches exactly by splitting the pattern at a critical factorization and scanning in two directions.

IntermediateCoreNo formula4 links
Pattern MatchingStringsMatching
Pattern MatchingO(n + m)

Crochemore-Perrin

Crochemore-Perrin addresses exact string matching by applying two-way matching with maximal suffix computation.

IntermediateExtendedNo formula3 links
Pattern MatchingStringsMatching
Pattern MatchingO(n + m)

Manber-Myers Suffix Array Construction

Manber-Myers Suffix Array Construction uses doubling prefix lengths and sorting suffix ranks iteratively for suffix array construction.

IntermediateCoreNo formula4 links
Pattern MatchingStrings
Pattern MatchingO(n + m)

SA-IS Suffix Array Construction

SA-IS Suffix Array Construction addresses suffix array construction by inducing suffix order from recursively sorted LMS substrings.

AdvancedSpecializedNo formula4 links
Pattern MatchingStringsDivide and Conquer
Pattern MatchingO(n + m)

Kasai LCP Algorithm

Computes the LCP array from a suffix array in linear time.

IntermediateCoreFormula3 links
Pattern MatchingStrings
Pattern MatchingO(n + m)

Prefix Function

Computes the longest proper border length for every prefix of a string.

IntermediateCoreNo formula3 links
Pattern MatchingStringsMatching
Pattern MatchingO(n + m)

Morris-Pratt

Morris-Pratt uses using prefix borders to avoid rechecking matched characters for exact string matching.

IntermediateCoreNo formula3 links
Pattern MatchingStringsMatching
Pattern MatchingO(n + m)

Horspool Algorithm

Finds exact string matches by shifting with the bad-character rule from the pattern's last position.

IntermediateCoreNo formula3 links
Pattern MatchingStringsMatching
Pattern MatchingO(n + m)

Sunday Quick Search

Searches for a pattern by shifting according to the character just after the current window.

IntermediateCoreNo formula3 links
Pattern MatchingStringsMatching
Pattern MatchingO(n + m)

Gotoh Algorithm

Gotoh Algorithm addresses affine-gap sequence alignment by using separate dynamic-programming states for opening and extending gaps.

IntermediateExtendedNo formula5 links
Pattern MatchingStrings
Pattern MatchingO(n + m)

Affine Gap Alignment

Affine Gap Alignment addresses sequence alignment by penalizing gap openings more than gap extensions.

IntermediateExtendedNo formula5 links
Pattern MatchingStrings
Pattern MatchingO(n + m)

Hirschberg Algorithm

Computes sequence alignment using divide and conquer to reduce memory.

IntermediateCoreNo formula5 links
Pattern MatchingStringsDynamic Programming