Skip to content

Latest commit

 

History

History
330 lines (223 loc) · 6.57 KB

File metadata and controls

330 lines (223 loc) · 6.57 KB

🔍 Search Algorithm Comparison Tool

A modern Python desktop application for visualizing, comparing, and benchmarking classical search and sorting algorithms through an interactive dark-themed graphical interface built with Tkinter and Matplotlib.

Python Tkinter Matplotlib License


📌 Overview

The Search Algorithm Comparison Tool is an interactive desktop application that demonstrates how different search and sorting algorithms perform on the same dataset.

Instead of simply displaying the search result, the application benchmarks each algorithm by measuring:

  • ✅ Search result
  • ✅ Number of comparisons
  • ✅ Execution time
  • ✅ Runtime visualization
  • ✅ Performance comparison
  • ✅ Sorting visualization

The project was developed to help students understand algorithm efficiency while providing an attractive GUI for experimentation and learning.


✨ Features

🔎 Search Algorithms

Compare multiple searching techniques on the same dataset.

  • Linear Search
  • Binary Search
  • Binary Search Tree (BST)
  • Red-Black Tree (Self-Balancing BST)

The application displays:

  • Search result (Found / Not Found)
  • Index (where applicable)
  • Number of comparisons
  • Execution time
  • Fastest algorithm
  • Performance comparison chart

📊 Sorting Algorithms

Visualize and compare sorting algorithms.

Supported algorithms include:

  • Bubble Sort
  • Insertion Sort
  • Merge Sort
  • Quick Sort

Features include:

  • Generate random datasets
  • Custom user input
  • Before/After visualization
  • Runtime measurement

📈 Runtime Benchmarking

Benchmark all search algorithms across multiple dataset sizes.

The application automatically:

  • Generates random datasets
  • Executes every search algorithm
  • Records execution time
  • Displays runtime graphs
  • Supports Linear Scale
  • Supports Logarithmic Scale

🎨 Modern User Interface

The application includes a clean dark-themed interface with:

  • Modern Tkinter layout
  • Responsive window
  • Organized tabs
  • Interactive charts
  • Results table
  • Winner banner
  • Real-time updates

🚀 Algorithms Included

Search Algorithms

Algorithm Average Time Worst Time Space Complexity Requires Sorted Data
Linear Search O(n) O(n) O(1) ❌ No
Binary Search O(log n) O(log n) O(log n) ✅ Yes
Binary Search Tree O(log n) Average O(n) O(n) ❌ No
Red-Black Tree O(log n) O(log n) O(n) ❌ No

Sorting Algorithms

Algorithm Average Time Worst Time Space
Bubble Sort O(n²) O(n²) O(1)
Insertion Sort O(n²) O(n²) O(1)
Merge Sort O(n log n) O(n log n) O(n)
Quick Sort O(n log n) O(n²) O(log n)

🛠️ Tech Stack

Programming Language

  • Python 3.10+

GUI Framework

  • Tkinter
  • ttk Widgets

Visualization

  • Matplotlib

Data Structures

  • Arrays
  • Binary Search Tree
  • Red-Black Tree

Algorithms

  • Linear Search
  • Binary Search
  • Bubble Sort
  • Insertion Sort
  • Merge Sort
  • Quick Sort

📂 Project Structure

search-algorithm-comparison/
│
├── app.py
├── linear_search.py
├── binary_search.py
├── binary_search_tree.py
├── red_black_tree.py
├── sorting_algorithms.py
│
├── tests/
│   └── test_sorting.py
│
├── requirements.txt
├── README.md
└── .gitignore

⚙️ Installation

Clone Repository

git clone https://github.com/yourusername/search-algorithm-comparison.git

cd search-algorithm-comparison

Install Dependencies

pip install -r requirements.txt

Run Application

python app.py

💻 Usage

Search Tab

  1. Generate a random array or enter custom values.
  2. Enter the target value.
  3. Select one search algorithm or compare all.
  4. Click Run Search.
  5. View:
  • Search result
  • Comparisons
  • Execution time
  • Winner
  • Comparison chart

Sorting Tab

  1. Generate random data.
  2. Select a sorting algorithm.
  3. Click Sort It!
  4. Compare:
  • Original array
  • Sorted array
  • Runtime

Runtime Charts

  1. Enter maximum input size.
  2. Select benchmark steps.
  3. Generate runtime charts.
  4. Compare algorithm scalability using:
  • Linear Scale
  • Logarithmic Scale

📊 Performance Metrics

The application evaluates each algorithm using:

  • Execution Time
  • Number of Comparisons
  • Search Success
  • Search Index
  • Runtime Complexity
  • Scalability

🐞 Improvements Over Previous Version

The latest version includes several improvements and bug fixes:

✔ Fixed BST search returning incorrect results when value was not found.

✔ Fixed Red-Black Tree integer printing issue.

✔ Prevented duplicate labels after multiple searches.

✔ Increased application window size from 750×250 to 1100×780.

✔ Added comparison counters to every search algorithm.

✔ Added runtime benchmarking charts.

✔ Added sorting visualization.

✔ Improved UI with modern dark theme.

✔ Enhanced overall responsiveness and layout.


📷 Application Modules

  • 🔍 Search Comparison
  • 📊 Sorting Visualization
  • 📈 Runtime Benchmarking
  • 🏆 Winner Detection
  • 📋 Result Table
  • 📉 Comparison Charts

🎯 Learning Objectives

This project demonstrates:

  • Searching Algorithms
  • Sorting Algorithms
  • Algorithm Analysis
  • Time Complexity
  • Space Complexity
  • Data Structures
  • Performance Benchmarking
  • GUI Development with Tkinter
  • Data Visualization using Matplotlib

🔮 Future Enhancements

  • Animated algorithm visualization
  • Additional sorting algorithms
  • Additional tree structures
  • Export benchmark results to CSV
  • Save performance reports
  • Adjustable visualization speed
  • Support for larger datasets
  • Memory usage analysis

📄 License

This project was developed for educational and academic purposes.

Feel free to use, modify, and extend it for learning and research.