Java implementations and algorithms of BoyerβMoore and KnuthβMorrisβPratt (KMP) string matching algorithms, created for a university assignment. Includes visual heuristics and brief, step-by-step notes.
- Part A: Concept of string matching + BM implementation with commented code.
- Part B: BM variations (e.g., Horspool) β discuss key differences & complexities (add to notes if needed).
- Part C: KMP overview + comparison with BM (time/space, strengths/weaknesses, scenarios).
- BoyerβMoore (BM): Skips characters using Bad Character and Good Suffix heuristics for practical speedups.
- KMP: Uses a failure function (prefix function) to avoid re-checking matched text.
algorithms/
ββ boyer-moore/
β ββ imgs/
β β ββ badCharHeuristic.png
β β ββ bmPatternMatching.png
β β ββ goodSuffixHeuristic.png
β ββ BadCharHeuristic.psu.md
β ββ BMPatternMatch.psu.md
β ββ BoyerMooreAlgo.java
β ββ GoodSuffixHeuristic.psu.md
ββ kmp/
β ββ imgs/
β β ββ kmpFailureFunction.png
β β ββ kmpPatternMatch.png
β ββ kmpFailureFunction.psu.md
β ββ kmpPatternMatch.psu.md
ββ README.md
- Install Latest JDK.
- Open a terminal in the algorithm folder (e.g.,
algorithms/boyer-moore
). - Compile:
javac BoyerMooreAlgo.java
- Run:
java BoyerMooreAlgo
- Boyer-Moore with Bad Character & Good Suffix heuristics.
- KMP with Failure (LPS) table construction.
- Concise algorithms in
.psu.md
files.
Special thanks to all contributors of this project.
Muhammad Ammar Danial Abdullah |
Ng Xuan Hern |
Low Yvonne |
Lim Wei Ling |
Note: This repository is for educational purposes and demonstration only.