Bornat Visualizer
AlgorithmsData StructuresNeural NetPracticePlaygroundCompareDocs

String Algorithms

Pattern matching from naive scans to KMP failure functions and rolling hashes.

5 visualizations

Compare

Naive Pattern Matching

Tries the pattern at every text position, comparing character by character — simple but O(nm).

Beginnerstring matchingbrute force

Knuth–Morris–Pratt (KMP)

Precomputes a failure function so mismatches skip ahead without ever re-scanning text — O(n + m).

Advancedstring matchingfailure function

Rabin-Karp String Matching

Hashes each text window and only compares characters when hashes collide — average O(n + m).

Intermediatestring matchingrolling hash

Z-Algorithm

Computes for every position the longest match with the string's own prefix (Z-array) in O(n), finding all pattern occurrences.

Advancedstring matchingZ-array

Boyer-Moore (Bad Character Rule)

Compares the pattern right-to-left and uses the bad-character rule to skip large chunks of text — often sublinear in practice.

Advancedstring matchingbad character rule
Bornat Data Structure Visualizer

Learn, visualize, experiment, and master data structures & algorithms with fully interactive, step-by-step animations.

Made with by Jibreel Bornat

Computer Engineering — Birzeit University

Explore

  • Sorting
  • Searching
  • Linked Lists
  • Stacks & Queues
  • Hashing
  • Trees
  • Graphs

App

  • All Algorithms
  • Practice
  • Playground
  • Documentation
  • About
  • Settings
Bornat Data Structure Visualizer© All Rights Reserved