Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Time-Complexity Visualizer (Python & Java)

This project helps visualize how the running time of algorithms grows as the input size increases.
It includes:

  • A Python time complexity visualizer that benchmarks algorithms and plots input size vs running time.
  • A Java merge sort visualizer that displays an animated bar chart as the array gets sorted.

🚀 Features

Python – Time Complexity Visualizer

  • Generic time_complexity_visualizer(algorithm, n_min, n_max, n_step) function.
  • Measures execution time for different input sizes.
  • Plots Input Size vs Running Time (seconds) using Matplotlib.
  • Currently includes:
    • linear_search(n) → simulates an O(n) search.
    • bubble_sort(n) → classic O(n²) sorting on random arrays.
  • Easy to extend with your own algorithms.

Java – Merge Sort Visualizer

  • Visualizes Merge Sort using a bar chart in a Swing window.
  • Each bar represents an element in the array.
  • Bars update as the algorithm runs, giving an intuitive feel for divide-and-conquer.

🧠 How It Works (Python)

The core function:

  • Takes an algorithm function that accepts an integer n (input size).
  • Runs the algorithm for values from n_min to n_max with step size n_step.
  • Uses time.time() to measure runtime.
  • Uses matplotlib to plot the results.

⚠️ Note: This gives an experimental feel for time complexity, not a mathematically perfect one.
Things like CPU load, Python interpreter overhead, and small input sizes can affect measurements.

Input arguments:

  • algorithm: function to benchmark (takes an integer n as input)
  • n_min: minimum input size
  • n_max: maximum input size
  • n_step: step size between input sizes

Output:

  • A plot showing running time vs input size for the given algorithm.

📂 Project Structure

.
├── python/
│   └── main.py                 # Time complexity visualizer and algorithms
├── java/
│   └── AlgorithmVisualizer.java # Merge sort visualizer (Swing)
└── LICENSE                     # GNU GPL v3

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages