Skip to content

About

Java tool that benchmarks 8 algorithms and compares real runtime vs theoretical Big-O complexity

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Algorithm Complexity Analyser

A Java-based benchmarking tool that measures and compares the real-world runtime of 8 classic algorithms — 4 sorting and 4 graph — across varying input sizes. Built to explore how theoretical Big-O complexity translates to actual performance.


What This Project Does

Most CS students learn Big-O complexity in theory. This project actually measures it. It runs each algorithm on randomly generated inputs, records the time taken in milliseconds, and compares results — revealing real observations like cache effects, input-sensitivity of Quick Sort, and the exponential slowdown of Bubble Sort at scale.


Algorithms Covered

Sorting

Algorithm Time Complexity Space
Bubble Sort O(n²) O(1)
Merge Sort O(n log n) O(n)
Quick Sort O(n log n) avg O(log n)
Heap Sort O(n log n) O(1)

Graph

Algorithm Time Complexity Use Case
BFS O(V + E) Shortest path (unweighted)
DFS O(V + E) Cycle detection, traversal
Dijkstra O(V²) Shortest path (weighted)
Bellman-Ford O(V × E) Handles negative weights

Key Observations from Running This Tool

  • Bubble Sort was 40–60x slower than Quick Sort at n=10,000 — confirming the O(n²) vs O(n log n) gap
  • Quick Sort outperformed Merge Sort on random inputs due to cache locality
  • Heap Sort showed consistent performance — no best/worst case variation
  • BFS and DFS performed similarly on dense graphs; DFS was slightly faster due to stack efficiency

Project Structure

AlgorithmAnalyser/
├── src/
│   ├── Main.java          # Entry point, menu-driven interface
│   ├── Algorithms.java    # All 8 algorithm implementations
│   ├── Benchmarker.java   # Timing logic and data generation
│   └── ResultSaver.java   # Saves results to file with timestamp
├── results/
│   └── analysis_results.txt   # Auto-generated after each run
└── README.md

How to Run

Requirements

  • Java JDK 8 or above
  • Any terminal (Command Prompt, PowerShell, or VS Code terminal)

Steps

# Step 1: Clone the repository
git clone https://github.com/VijayaDurgaKondeti/AlgorithmComplexityAnalyser.git
cd AlgorithmComplexityAnalyser

# Step 2: Compile all Java files
javac -d out src/*.java

# Step 3: Run the program
java -cp out Main

Sample Output

╔══════════════════════════════════════════════╗
║     Algorithm Complexity Analyser v1.0       ║
║     Kondeti Vijaya Durga | B.Tech AIML       ║
╚══════════════════════════════════════════════╝

  MAIN MENU
  1. Run Sorting Algorithm Analysis
  2. Run Graph Algorithm Analysis
  3. Run Full Analysis (All 8 Algorithms)
  4. View Previous Results
  5. Exit

  Choose an option: 1
  Enter input size for sorting: 10000

SORTING ALGORITHMS — Input Size: 10000
─────────────────────────────────────────────
  Bubble Sort          : 312 ms  | Expected: O(n^2)
  Merge Sort           : 8 ms    | Expected: O(n log n)
  Quick Sort           : 5 ms    | Expected: O(n log n) avg
  Heap Sort            : 7 ms    | Expected: O(n log n)
─────────────────────────────────────────────
  Fastest: Quick Sort at 5 ms
  Observation: Bubble Sort is 62x slower than Quick Sort at n=10000

Tech Stack

  • Language: Java (JDK 8+)
  • Concepts: Algorithm Design, Big-O Analysis, OOP, File I/O
  • Tools: VS Code, Git, GitHub

Why I Built This

I wanted to move beyond just solving LeetCode problems and actually understand why certain algorithms are faster. This project helped me see that theoretical complexity and real-world performance are related but not identical — cache behavior, input patterns, and recursion overhead all play a role. That gap between theory and observation is what computer science research is about.


Author

Kondeti Vijaya Durga B.Tech AIML — Mohan Babu University LinkedIn | GitHub

About

Java tool that benchmarks 8 algorithms and compares real runtime vs theoretical Big-O complexity

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages