Skip to content

Java implementations and algorithms of Boyer-Moore and KMP string matching algorithms for a university assignment.

Notifications You must be signed in to change notification settings

Some0ne11/string-matching-algorithms

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

πŸ”Ž String Matching Algorithms: Boyer-Moore & KMP

Java Algorithms Education

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.

πŸ“ Assignment Mapping

  • 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).

πŸ“š Overview

  • 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.

πŸ—‚ Repository Structure

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

πŸš€ Run the Code (Java)

  1. Install Latest JDK.
  2. Open a terminal in the algorithm folder (e.g., algorithms/boyer-moore).
  3. Compile:
    javac BoyerMooreAlgo.java
  4. Run:
    java BoyerMooreAlgo

🧩 What’s Included

  • Boyer-Moore with Bad Character & Good Suffix heuristics.
  • KMP with Failure (LPS) table construction.
  • Concise algorithms in .psu.md files.

🀝 Team Members

Special thanks to all contributors of this project.

Profile Picture
Muhammad Ammar Danial Abdullah
Profile Picture
Ng Xuan Hern
Profile Picture
Low Yvonne
Profile Picture
Lim Wei Ling

Note: This repository is for educational purposes and demonstration only.

About

Java implementations and algorithms of Boyer-Moore and KMP string matching algorithms for a university assignment.

Topics

Resources

Stars

Watchers

Forks

Languages

  • Java 100.0%