Skip to content

Repository files navigation

Cyberpunk Search Studio

Algorithm Laboratory for String Search Performance Analysis

A JavaFX application for implementing, testing, and benchmarking three core string search algorithms: Rabin-Karp, Boyer-Moore, and Knuth-Morris-Pratt (KMP). Features virtualized rendering for large documents and real-time performance analysis.


🎯 Overview

Cyberpunk Search Studio provides an interactive environment for comparing classical string search algorithms on real text data. The application handles large documents efficiently and includes comprehensive benchmarking tools for performance analysis.

Key Features
  • 🔍 Three Core Algorithms: Rabin-Karp (3 variants), Boyer-Moore, and KMP
  • Virtualized Rendering: Smooth handling of large documents (millions of characters)
  • 📊 Performance Benchmarking: Compare algorithm execution times on actual loaded content
  • 🎯 Search Modes: Substring, starts-with, and whole-word matching
  • 🔄 Search & Replace: Find and replace with visual feedback
  • 💾 File Operations: Load and save text documents

Main application interface

Figure 1: Main application interface with search toolbar and text viewport


🧬 Core Algorithms

1️⃣ Rabin-Karp

Rolling Hash

Three implementations:

  • Naive (Summation)
  • Polynomial Modulo
  • Bitwise Shift (Optimized)

Time: O(n + m) avg
Space: O(1)

Best For: Large texts, multilingual content

2️⃣ Boyer-Moore

Right-to-Left Matching

Uses bad character and good suffix rules

Time: O(n/m) avg
Space: O(m + σ)

Best For: Long patterns, general-purpose

3️⃣ KMP

Linear-Time Algorithm

LPS array preprocessing

Time: O(n + m) guaranteed
Space: O(m)

Best For: Guaranteed performance, streaming

Additional algorithms (Naive, Horspool, Bitap, Z-Algorithm) are included for benchmark comparison purposes.


💡 Rabin-Karp Hash Parameters:
Base: 65,537 | Modulus: 1,000,000,007
Supports Unicode, emojis, and multilingual text


Algorithm selection dropdown

Figure 2: Dropdown Menu to select which algorithm to use in search


📖 Usage Guide

💡 Quick Start: Launch → Load File → Select Algorithm → Enter Pattern → Click SEARCH


🚀 Getting Started

Step Action
1️⃣ Launch Application: Run JAR file or execute from IDE
2️⃣ Default Text: Application loads with sample text pre-loaded

📂 Loading Files

  1. Click the LOAD button in the top toolbar
  2. Select any text file (UTF-8 encoded)
  3. The document will load and display in the center view

Searching for Patterns

Step-by-Step Process:

  1. Select Algorithm → Choose from dropdown (default: RABIN-KARP 3 (Opt))
  2. Choose Search Mode:
    • 📄 SUBSTRING - Find pattern anywhere in text
    • 🔤 STARTS_WITH - Pattern must start at word boundaries
    • 📝 WHOLE_WORD - Pattern must match complete words
  3. Toggle Case → Check IGNORE CASE for case-insensitive search
  4. Enter Pattern → Type search text (default: "you")
  5. Click SEARCH → Matches highlighted in cyan with glow effects
  6. View Results → Command log shows match count and execution time

🔄 Search & Replace

  1. Perform a search first (establishes match positions)
  2. Enter Replacement: Type replacement text in the "Replace..." field
  3. Click REPLACE: All matches are replaced in the document
  4. View Changes: Text updates immediately in the viewport

Saving Files

  1. Click SAVE AS button
  2. Choose location and filename
  3. File saves with all replacements applied
  4. Confirmation appears in command log

📊 Benchmarking Performance

How to Run:

  1. 📂 Load your target document
  2. ✍️ Enter the search pattern you want to test
  3. 🎯 Click BENCHMARK → Switches to dashboard view
  4. 📈 View Results:
    • Each algorithm shows average execution time
    • Visual bars compare relative performance
    • 🏆 Winner highlighted in green
    • Results sorted fastest → slowest

⚙️ Benchmark Process:

  • 🔥 Warm-up: 10 iterations (JIT optimization)
  • 📏 Measurement: 20 iterations (statistical accuracy)
  • 📄 Uses your actual loaded document and pattern
  • ⏱️ Reports average time in milliseconds

Search results Benchmark dashboard

Figure 3, 4: Benchmarking Results


🎛️ Interface Components

🔝 Top Toolbar

  • LOAD - Open files
  • Algorithm selector
  • Mode selector
  • IGNORE CASE checkbox
  • Pattern field
  • Replace field
  • Action buttons

📱 Center View

  • 25K character window
  • Cyan highlights
  • Smooth scrolling
  • Dynamic rendering
  • Buffer indicator

📟 Bottom Panel

  • Command log
  • Operation history
  • Performance metrics
  • Status indicators
  • Real-time feedback

💡 Tips for Best Results

  • Large Files: The viewport renders only visible text, so documents with millions of characters work smoothly
  • Pattern Selection: Shorter patterns typically search faster across all algorithms
  • Benchmark Accuracy: Use realistic patterns and actual working documents for meaningful comparisons
  • Scrolling: After search, scroll through document to see all matches highlighted
  • Multiple Searches: Each new search clears previous highlights

⚡ Performance Characteristics

Algorithm Average Time Space Best Use Case
Rabin-Karp (Bitwise) O(n + m) O(1) Large texts, multiple patterns
Boyer-Moore O(n/m) O(m + σ) Long patterns, general use
KMP O(n + m) O(m) Guaranteed linear time

n = text length, m = pattern length, σ = alphabet size


🚀 Running the Application

Prerequisites

  • ☕ Java 11 or higher
  • 🎨 JavaFX SDK

Quick Start

java -jar cyberpunk-search-studio.jar

Build & Run

# With Maven
mvn clean package
java --module-path /path/to/javafx-sdk/lib \
     --add-modules javafx.controls \
     -jar target/search-benchmark.jar

🎯 Use Cases

📚
Algorithm Education

Compare and understand classical search algorithms


Performance Testing

Benchmark algorithms on real-world data

📝
Text Processing

Search and replace in large documents

🔬
Research

Analyze algorithm behavior with different patterns


📊 Sample Benchmark Results

Typical results on a 1MB text file:

🏆 RABIN-KARP 3 (Opt)  : 0.0234 ms (Winner)
🥈 Boyer-Moore         : 0.0312 ms
🥉 KMP                 : 0.0389 ms

Results vary based on hardware, document characteristics, and pattern complexity


🛠️ Technical Details

⚙️ Rabin-Karp Configuration

  • Base: 65,537
  • Modulus: 1,000,000,007
  • Support: Unicode, emojis, multilingual

🖥️ Virtualization System

  • Window Size: 25,000 characters
  • Rendering: On-demand during scroll/search
  • Spacers: Dynamic height simulation

🌟 Built with JavaFX | Implementing Classical String Search Algorithms

Made with ❤️ for Algorithm Education & Performance Analysis

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages