String Matching — Interactive Companion

Interactive visualizations for Chapter 1 of the Advanced Algorithms notes


1. Naive String Matching

Slide through every alignment of P against T and see which characters match.


3. Z-Algorithm

Visualize the Z-array: Z[k] = length of the longest substring starting at k that matches a prefix of S.


4. Boyer-Moore — Bad Character Rule

Step through the Boyer-Moore search. The algorithm scans the pattern right-to-left and uses the bad character rule to skip alignments.


5. Suffix Trie & Suffix Tree

Build and visualize the suffix trie and its compacted suffix tree for any input string.


6. Algorithm Comparison

Run all algorithms on the same input and compare the number of character comparisons.


7. Keyword Tree — Multiple Pattern Matching

7a. Building the Keyword Tree

Enter a comma-separated list of patterns and see the resulting keyword tree. The stats panel shows size (number of edges), height (longest pattern), and maximum fan-out.


7b. Searching with the Keyword Tree

Enter a text and patterns. Step through each starting position to see the descent from the root: active edges light up, non-matching branches are grayed out.