Skip to content
ExtendedSource checked

Crochemore-Perrin

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

Quick Facts

Compact metadata for implementation and discovery.

Category
Pattern Matching
Difficulty
Intermediate
Family
Exact String Matching
Tier
Extended
Status
Verified
Review
Source Checked
Sources
1
Formulas
0
Relationships
3
Code example
Ready
Visualization
Ready

Overview

Crochemore-Perrin is a exact string matching method for exact string matching. It works by applying two-way matching with maximal suffix computation.

Core Concepts

exact string matchingmatchingsuffix structurepattern matching

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(n)

Average

O(n + m)

Worst

O(n + m)

Space

O(n + m)

When to Use

  • Use Crochemore-Perrin when solving exact string matching and you want to benefit from applying two-way matching with maximal suffix computation.
  • Choose it when O(n + m) average/worst-case time and O(n + m) memory match your workload profile.
  • Prefer it over Bit-Parallel Levenshtein or Shift-And Algorithm when the problem structure favors exact string matching.

When Not to Use

  • Avoid when preprocessing cost is larger than the savings for a one-off tiny input.
  • Avoid when the alphabet or scoring assumptions do not match the sequence data.

What It Does

  • Computes exact string matching within Exact String Matching workloads (O(n + m) time, O(n + m) space).
  • Works by applying two-way matching with maximal suffix computation.
  • Maintains key invariants across exact string matching, matching, suffix structure.

Use Cases

  • Production and research workloads requiring exact string matching via applying two-way matching with maximal suffix computation.
  • Exact String Matching pipelines where O(n + m) time and O(n + m) space fit system constraints.
  • Engineering comparisons against Bit-Parallel Levenshtein and Shift-And Algorithm when tuning exact string matching.

Inputs

  • Text or sequence
  • Pattern, index, or comparison sequence

Outputs

  • Matches, alignment, index, or similarity value

Pseudocode

  1. 1.Preprocess the input alphabet, pattern/grammar rules, or symbol frequency tables for Crochemore-Perrin.
  2. 2.Construct the lookup automaton, suffix/shift index, or coding state (exact string matching, matching).
  3. 3.Scan the input sequence by applying two-way matching with maximal suffix computation.
  4. 4.Emit matches, derivation nodes, or encoded tokens while advancing the state transition table.
  5. 5.Finalize trailing state and return the completed exact string matching output.

Canonical Example

Input
Text or sequence configured for a representative exact string matching test case
Output
Matches, alignment, index, or similarity value satisfying Crochemore-Perrin invariants
Explanation
Crochemore-Perrin processes the input by applying two-way matching with maximal suffix computation, tracking exact string matching and matching to produce the verified exact string matching result.

Implementation Notes

  • Keep preprocessing output inspectable with short examples.
  • Test repeated characters and overlapping matches.
  • Document sentinel or alphabet assumptions.

Common Pitfalls

  • Mishandling empty patterns, repeated characters, or sentinel symbols.
  • Confusing preprocessing indexes with the query algorithm.
  • Forgetting whether indexing is zero-based or one-based.

Interactive Mechanism Walkthrough

Sequence Window & Automaton Alignment

Show applying two-way matching with maximal suffix computation on a small exact string matching example.

Input:ABABABCABAB
Window:ABAB
Step 1 of 5: Preprocess the input alphabet, pattern/grammar rules, or symbol frequency tables for Crochemore-Perrin.
pattern-matching-mechanism

Notes

Crochemore-Perrin operates in O(n + m) time and O(n + m) space within the Exact String Matching family. Often compared with Bit-Parallel Levenshtein and Shift-And Algorithm.

Sources (1)

What each reference supports for this entry.

Jewels of Stringology

Book

Stringology reference for two-way string matching and Crochemore-Perrin style critical factorization.

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Crochemore-Perrin and Bit-Parallel Levenshtein are practical alternatives within exact string matching, with different assumptions and tradeoffs.

Alternative toShift-And Algorithm

Crochemore-Perrin and Shift-And Algorithm are practical alternatives within exact string matching, with different assumptions and tradeoffs.

Alternative toShift-Or Algorithm

Crochemore-Perrin and Shift-Or Algorithm are practical alternatives within exact string matching, with different assumptions and tradeoffs.

Tags

Pattern MatchingStringsMatching