Visualize Big O: Algorithm Speed Tester
Build a Python tool that benchmarks and charts algorithm complexity curves.
Introduction
30 Second Summary
Every app you use makes choices about how to process data. The difference between an app that responds instantly and one that freezes on large inputs comes down to which algorithm it uses.
In this project, you will build a Python benchmarking tool that times different algorithms on growing datasets, then generates charts showing exactly how their speed changes as data scales up.
What You'll Build
A Python script that implements four categories of algorithms, measures their execution time across input sizes from 100 to 100,000 elements, and generates a multi-line chart comparing their growth curves using matplotlib.
By the end of this project, you'll have:
- A working benchmarking tool that times algorithms on increasing input sizes and prints raw timing data.
- Matplotlib charts proving how O(1), O(n), O(n log n), and O(n²) grow differently at scale.
- Hands-on intuition for classifying any function's time complexity by observing its growth curve.
- Secret Mission: Add a recursive Fibonacci function and use memoization to visually prove how it drops from O(2^n) to O(n).
Are there any prerequisites?
You should be comfortable with basic Python concepts like loops, functions, and lists. No prior knowledge of Big O notation or data visualization is required.
Before We Start
You are about to build a tool that proves something engineers talk about every day: why some code crawls and other code flies. Big O notation is how developers predict whether their code will still work when the data doubles, triples, or grows a thousandfold.
Instead of memorizing theory, you will write real algorithms, time them on real data, and generate charts that make the speed differences impossible to ignore. In this step, you will set up your project folder, confirm Python is ready, and install the charting library you need.
In this step, get ready to:
- Create the project folder and confirm Python is installed.
- Install the matplotlib charting library.
- Create the three Python files for the project.
Create the project folder and verify Python
Every project needs a dedicated folder so your files stay organized and your terminal commands run in the right place.
- Press Cmd+Space (macOS) or the Windows key (Windows) to open your search bar.
- Type Terminal and press Enter to open it.
- Move to your Desktop by running this command:
cd ~/Desktop
- Create your project folder and move into it by running these commands:
mkdir big-o-lab
cd big-o-lab
- Confirm the folder exists by running:
ls ~/Desktop
You should see big-o-lab listed in the output.
- Now open VS Code. Press Cmd+Space (macOS) or the Windows key (Windows) to open your search bar.
- Type VS Code and press Enter to open it.
- Click File in the top menu bar.
- Click Open Folder.
- Navigate to your Desktop and select the big-o-lab folder, then click Open.
Why open the folder in VS Code?
Opening the folder (not just a single file) tells VS Code to treat big-o-lab as your workspace. The integrated terminal will start inside this folder automatically, and the file explorer on the left will show only your project files.
- Open the integrated terminal in VS Code by pressing Ctrl+` (backtick key, next to the number 1).
- Verify Python is installed by running this command:
python3 --version
You should see a version number like Python 3.10.x or higher printed in the terminal.
Don't see a version number?
If you see command not found, Python 3 may not be installed or may not be on your system PATH. Visit python.org to download and install the latest Python 3 release, then restart your terminal and try again.
If you see a version lower than 3.10, you will need to upgrade. The matplotlib version we use requires Python 3.10 or higher.
help me fix my Python installation so I can run python3 --version successfully
Install matplotlib
Matplotlib is Python's standard charting library. You will use it to plot the speed curves that make Big O differences visible.
- Install matplotlib by running this command:
pip3 install matplotlib==3.10.9
- Verify the installation worked by running:
python3 -c "import matplotlib; print(matplotlib.__version__)"
You should see 3.10.9 printed in the terminal.
Seeing a permission error or install failure?
If you see a permission denied error, try adding --user to the end of the pip command. This installs the package to your user directory instead of the system-wide location.
If you see an error about pip not being found, try using pip instead of pip3, or run python3 -m pip install matplotlib==3.10.9 as an alternative.
help me install matplotlib for my Python 3 project
Create the three project files
Your project uses three separate files to keep concerns separate: one for algorithms, one for benchmarking, and one for visualization.
- Create all three files by running this command:
touch algorithms.py benchmark.py visualize.py
- Confirm the files exist by running:
ls
You should see algorithms.py, benchmark.py, and visualize.py listed in the output.
What are these three files for?
- algorithms.py holds the algorithm implementations you want to compare.
- benchmark.py holds the timing harness that measures how long each algorithm takes.
- visualize.py holds the plotting code that turns raw numbers into a chart.
Don't see the files?
Make sure your terminal is inside the big-o-lab folder. Run pwd to check your current location. You should see a path ending in /big-o-lab.
You should also see the three files appear in the VS Code Explorer sidebar on the left. If the sidebar is collapsed, click the top icon (two overlapping files) to expand it.
help me find my project files in VS Code
Your workspace is ready to go. Next up, you will write four algorithms that represent the most common Big O complexity classes and see how they behave on real data.
Implement Algorithms from Four Complexity Classes
Your environment is ready with Python, matplotlib, and three empty files waiting to be filled.
Now it's time to write the actual algorithms you'll be benchmarking. Each function you write belongs to a different Big O complexity class, from instant (O(1)) to painfully slow (O(n²)).
In this step, get ready to:
- Write constant-time and linear-time functions.
- Write a linearithmic-time sorting function.
- Write a quadratic-time sorting function.
Write constant-time and linear-time functions
A constant-time function always takes the same amount of time regardless of how big the input is. A linear-time function's execution time grows directly with the input size.
- Open algorithms.py in VS Code.
- Add the following code to implement your first two algorithms:
import random
def constant_access(data):
"""O(1) - Access the first element regardless of list size."""
return data[0]
def linear_search(data, target):
"""O(n) - Search through every element until target is found."""
for i in range(len(data)):
if data[i] == target:
return i
return -1
What does this code do?
- import random brings in the random module, which the benchmark harness will use later to generate test data.
- constant_access(data) grabs the first element of a list. Accessing an item by index is O(1) because it takes the same time whether the list has 10 items or 10 million.
- linear_search(data, target) loops through every element to find the target. In the worst case, it checks every single item, making it O(n).
- Save algorithms.py.
- Test these two functions by running this command in your terminal:
python3 -c "from algorithms import constant_access, linear_search; data = [5, 3, 8, 1, 9]; print(constant_access(data)); print(linear_search(data, 9))"
You should see 5 on the first line (the first element) and 4 on the second line (the index where 9 lives in the list).
Seeing a ModuleNotFoundError?
- Make sure your terminal is in the big-o-lab folder. Run pwd to check.
- Confirm you saved algorithms.py after pasting the code. Unsaved files won't be importable.
Help me fix this ModuleNotFoundError when importing algorithms
Write a linearithmic-time function
O(n log n) sits between linear and quadratic. It's the sweet spot for efficient sorting algorithms. Python's built-in sorted() function uses Timsort, which achieves O(n log n) performance.
- Add this function below linear_search in algorithms.py:
def sort_data(data):
"""O(n log n) - Python's built-in Timsort."""
return sorted(data)
What does this code do?
sort_data(data) wraps Python's sorted() builtin, which returns a new sorted list without modifying the original.
Timsort is a hybrid algorithm combining merge sort and insertion sort. It's O(n log n) because it repeatedly divides the data into halves (log n splits) and merges them back together (n work per merge level).
- Save algorithms.py.
You won't see a change yet. The next chunk adds the final algorithm, then you'll test all four together.
Write a quadratic-time function
O(n²) algorithms use nested loops where each element is compared against every other element. Bubble sort is the classic example. It's easy to understand but becomes catastrophically slow as data grows.
- Add this function below sort_data in algorithms.py:
def bubble_sort(data):
"""O(n^2) - Classic nested loop sort."""
arr = data.copy()
n = len(arr)
for i in range(n):
for j in range(0, n - i - 1):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
return arr
What does this code do?
- data.copy() creates a copy so the original list isn't modified.
- The outer loop (for i in range(n)) runs n times. The inner loop (for j in range(0, n - i - 1)) compares adjacent elements and swaps them if they're out of order.
- Because every element is compared against nearly every other element, the total comparisons approach n × n. That's what makes it O(n²).
- Save algorithms.py.
- Test all four algorithms on a small list by running:
python3 -c "from algorithms import constant_access, linear_search, sort_data, bubble_sort; data = [5, 3, 8, 1, 9]; print(constant_access(data)); print(linear_search(data, 9)); print(sort_data(data)); print(bubble_sort(data))"
You should see four lines of output:
- 5 (the first element, O(1)).
- 4 (index of 9 in the list, O(n)).
- [1, 3, 5, 8, 9] (sorted by Timsort, O(n log n)).
- [1, 3, 5, 8, 9] (sorted by bubble sort, O(n²)).
Getting unexpected output?
- If you see -1 instead of 4, check that your linear_search function uses == (double equals) for comparison, not = (assignment).
- If bubble sort returns the original unsorted list, make sure the swap line uses the comma syntax: arr[j], arr[j + 1] = arr[j + 1], arr[j].
- Check that your inner loop uses range(0, n - i - 1) with the minus 1 at the end. Without it, you'll get an index out of range error.
Help me debug my algorithm output
Why do both sort functions return the same result?
Both sort_data and bubble_sort produce the same sorted output. The difference isn't in the result. It's in how long they take to get there.
On a list of 5 elements, both finish instantly. On 100,000 elements, that difference becomes dramatic. That's exactly what you'll measure in the next step.
✔️ Awesome, I've got everything!
Great. Double check you've saved algorithms.py before moving on.
ⓧ I'd like to double check the full code
Here's the complete algorithms.py file. Make sure yours matches exactly:
import random
def constant_access(data):
"""O(1) - Access the first element regardless of list size."""
return data[0]
def linear_search(data, target):
"""O(n) - Search through every element until target is found."""
for i in range(len(data)):
if data[i] == target:
return i
return -1
def sort_data(data):
"""O(n log n) - Python's built-in Timsort."""
return sorted(data)
def bubble_sort(data):
"""O(n^2) - Classic nested loop sort."""
arr = data.copy()
n = len(arr)
for i in range(n):
for j in range(0, n - i - 1):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
return arr
You now have four algorithms that all produce correct results but take wildly different paths to get there. Next up, you'll build a benchmarking harness that measures exactly how long each one takes as the input grows.
Build the Benchmarking Harness
Your four algorithms are ready to race. Each one represents a different complexity class, but right now you have no way to prove which is faster or how their performance changes as data grows.
In this step, you will build a benchmarking harness that measures how long each algorithm takes to run on increasingly large inputs. By the end, you will have hard numbers showing exactly how Big O differences translate to real seconds.
In this step, get ready to:
- Write a timing utility function that measures any algorithm's execution time.
- Benchmark all four algorithms across input sizes from 100 to 100,000 elements.
- Run the benchmark and observe the raw timing data in the terminal.
Write the timing function in benchmark.py
To compare algorithms fairly, you need a way to measure how long each one takes. Python's time.perf_counter() gives you a high-resolution performance counter that measures fractional seconds with the highest precision available on your system.
- In VS Code, open benchmark.py from the Explorer sidebar.
- Add the imports and timing function by copying this code into the file:
import time
import random
from algorithms import constant_access, linear_search, sort_data, bubble_sort
def measure_time(func, *args):
"""Measure execution time of a function using perf_counter."""
start = time.perf_counter()
func(*args)
end = time.perf_counter()
return end - start
What does this code do?
The imports pull in Python's time module for timing, random for generating test data, and all four algorithm functions from your algorithms.py file.
The measure_time() function takes any function and its arguments, records the clock before and after running it, and returns the difference in seconds. This makes it reusable for timing any algorithm with any input.
Why perf_counter instead of timeit?
Python's timeit module is designed for micro-benchmarks of tiny code snippets. It runs code millions of times to average out noise. Your algorithms run on large inputs where each single run produces measurable differences, so time.perf_counter() is simpler and more transparent.
- Save benchmark.py.
Seeing a red underline on the import?
If VS Code shows an error on from algorithms import ..., make sure your algorithms.py file is saved and sits in the same folder as benchmark.py. Both files must be in the big-o-lab folder.
Help me fix my import error in benchmark.py
Write the benchmark loop
The benchmark loop tests each algorithm on progressively larger inputs. This reveals how each algorithm's execution time grows as data scales up.
- In benchmark.py, add the run_benchmarks() function below measure_time() by copying this code:
def run_benchmarks():
"""Run all algorithms across increasing input sizes."""
sizes = [100, 500, 1000, 5000, 10000, 50000, 100000]
results = {
"O(1) - Constant Access": [],
"O(n) - Linear Search": [],
"O(n log n) - Timsort": [],
"O(n^2) - Bubble Sort": [],
}
for size in sizes:
data = [random.randint(1, 1000000) for _ in range(size)]
target = data[-1]
# O(1)
t = measure_time(constant_access, data)
results["O(1) - Constant Access"].append(t)
# O(n)
t = measure_time(linear_search, data, target)
results["O(n) - Linear Search"].append(t)
# O(n log n)
t = measure_time(sort_data, data)
results["O(n log n) - Timsort"].append(t)
# O(n^2) - skip very large sizes to avoid long waits
if size <= 10000:
t = measure_time(bubble_sort, data)
results["O(n^2) - Bubble Sort"].append(t)
else:
results["O(n^2) - Bubble Sort"].append(None)
return sizes, results
What does this code do?
- sizes defines the input sizes to test: from 100 elements up to 100,000.
- results is a dictionary that stores each algorithm's timing data as a list of measurements.
- For each size, a random list of integers is generated. Then each algorithm runs on that same data so the comparison is fair.
- Bubble sort is skipped for sizes above 10,000 because quadratic scaling at 50,000+ elements would mean waiting several minutes. This is itself a Big O lesson.
- Save benchmark.py.
Not sure where to place this function?
Make sure run_benchmarks() starts on a new line below the measure_time() function. Leave two blank lines between the end of measure_time() and the def run_benchmarks(): line. Python uses this spacing convention to separate top-level functions.
Help me figure out where to place my run_benchmarks function
Run the benchmark and print raw results
The final piece is a main block that runs the benchmarks and prints the results as a formatted table. This lets you see the raw timing data before you visualize it as a chart.
- At the bottom of benchmark.py, add the main block by copying this code:
if __name__ == "__main__":
sizes, results = run_benchmarks()
print(f"{'Size':<10}", end="")
for name in results:
print(f"{name:<28}", end="")
print()
print("-" * 120)
for i, size in enumerate(sizes):
print(f"{size:<10}", end="")
for name in results:
t = results[name][i]
if t is not None:
print(f"{t:<28.6f}", end="")
else:
print(f"{'skipped':<28}", end="")
print()
What does this code do?
- if __name__ == "__main__": ensures this code only runs when you execute the file directly. It won't run when another file imports from benchmark.py.
- The print statements format each algorithm's times into aligned columns so you can compare them at a glance.
- Where bubble sort was skipped (sizes above 10,000), the table prints "skipped" instead of a time.
- Save benchmark.py.
✔️ Awesome, I've got everything!
Great. Double check you have saved your file before running it.
ⓧ I'd like to double check the full code
Here is the complete benchmark.py file. Compare yours against this:
import time
import random
from algorithms import constant_access, linear_search, sort_data, bubble_sort
def measure_time(func, *args):
"""Measure execution time of a function using perf_counter."""
start = time.perf_counter()
func(*args)
end = time.perf_counter()
return end - start
def run_benchmarks():
"""Run all algorithms across increasing input sizes."""
sizes = [100, 500, 1000, 5000, 10000, 50000, 100000]
results = {
"O(1) - Constant Access": [],
"O(n) - Linear Search": [],
"O(n log n) - Timsort": [],
"O(n^2) - Bubble Sort": [],
}
for size in sizes:
data = [random.randint(1, 1000000) for _ in range(size)]
target = data[-1]
# O(1)
t = measure_time(constant_access, data)
results["O(1) - Constant Access"].append(t)
# O(n)
t = measure_time(linear_search, data, target)
results["O(n) - Linear Search"].append(t)
# O(n log n)
t = measure_time(sort_data, data)
results["O(n log n) - Timsort"].append(t)
# O(n^2) - skip very large sizes to avoid long waits
if size <= 10000:
t = measure_time(bubble_sort, data)
results["O(n^2) - Bubble Sort"].append(t)
else:
results["O(n^2) - Bubble Sort"].append(None)
return sizes, results
if __name__ == "__main__":
sizes, results = run_benchmarks()
print(f"{'Size':<10}", end="")
for name in results:
print(f"{name:<28}", end="")
print()
print("-" * 120)
for i, size in enumerate(sizes):
print(f"{size:<10}", end="")
for name in results:
t = results[name][i]
if t is not None:
print(f"{t:<28.6f}", end="")
else:
print(f"{'skipped':<28}", end="")
print()
Now run the benchmark to see your algorithms in action.
- Run the benchmark script by entering this command in your terminal:
python3 benchmark.py
The script will take a few seconds to complete. You should see a formatted table with columns for each algorithm and rows for each input size. The numbers represent seconds of execution time.
What should I see?
Your table should show that constant access times stay nearly zero regardless of input size. Linear search grows steadily. Timsort grows slightly faster than linear. Bubble sort's times explode dramatically at sizes 5,000 and 10,000, then show "skipped" for the larger sizes.
Your exact numbers will differ from anyone else's since they depend on your computer's speed. The important thing is the relative growth pattern between the algorithms.
Seeing a ModuleNotFoundError?
Make sure your terminal is inside the big-o-lab folder. Run ls and confirm you see algorithms.py, benchmark.py, and visualize.py listed. If not, use cd big-o-lab to navigate into the project folder.
Help me fix my ModuleNotFoundError when running benchmark.py
You now have hard proof that algorithm choice matters. The numbers are clear, but staring at a table of decimals is not the easiest way to communicate this. Next up, you will turn these timing results into a visual chart that makes the growth patterns impossible to miss.
Visualize the Growth Curves
In the last step, you watched raw timing data scroll through your terminal. Numbers in a table are useful, but they don't reveal the shape of growth at a glance.
A chart does. In this step, you will use matplotlib to plot each algorithm's execution times on a single graph. The result is a visual proof that algorithm choice matters more than hardware speed.
In this step, get ready to:
- Write a plotting script that draws each algorithm's timing data as a line on a chart.
- Add axis labels, a title, and a legend so the chart is readable and self-explanatory.
- Generate a PNG file and inspect the four growth curves side by side.
Write the plotting code
The visualize.py file will import the run_benchmarks() function from your benchmarking harness, re-run the timing measurements, and draw one line per algorithm on a shared chart.
- Switch back to visualize.py in VS Code and paste the following code:
import matplotlib.pyplot as plt
from benchmark import run_benchmarks
def create_chart():
"""Generate a comparison chart of algorithm growth curves."""
sizes, results = run_benchmarks()
plt.figure(figsize=(10, 6))
for name, times in results.items():
# Filter out None values for plotting
plot_sizes = [sizes[i] for i in range(len(times)) if times[i] is not None]
plot_times = [t for t in times if t is not None]
plt.plot(plot_sizes, plot_times, marker="o", linewidth=2, label=name)
What does this code do?
- import matplotlib.pyplot as plt brings in matplotlib's plotting interface.
- from benchmark import run_benchmarks pulls your timing harness directly so the chart always uses fresh data.
- plt.figure(figsize=(10, 6)) creates a 10-by-6 inch canvas for the chart.
- The loop iterates over each algorithm's results. It filters out None values (the sizes where bubble sort was skipped) so matplotlib does not choke on missing data.
- plt.plot() draws one line per algorithm, using circle markers and a label for the legend.
You will not see a change yet. The next chunk adds the labels and save command that make the chart complete.
Style and label the chart
A chart without labels is just a tangle of lines. Axis labels, a title, and a legend turn raw data into a readable story.
- Still inside the create_chart() function in visualize.py, add the following code below the for loop:
plt.xlabel("Input Size (n)")
plt.ylabel("Time (seconds)")
plt.title("Big O in Action: Algorithm Speed vs. Input Size")
plt.legend()
plt.grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig("big_o_comparison.png", dpi=150)
print("Chart saved as big_o_comparison.png")
if __name__ == "__main__":
create_chart()
What do these lines do?
- plt.xlabel() and plt.ylabel() label the horizontal and vertical axes so a viewer knows what the numbers represent.
- plt.title() adds a descriptive heading above the chart.
- plt.legend() draws a color-coded key matching each line to its algorithm name and Big O class.
- plt.grid(True, alpha=0.3) overlays faint gridlines (30% opacity) so you can trace values across the chart.
- plt.savefig("big_o_comparison.png", dpi=150) writes the chart to a PNG file at 150 dots per inch.
- Save visualize.py.
Seeing a red underline on the import?
If VS Code shows a warning on from benchmark import run_benchmarks, make sure benchmark.py is in the same folder as visualize.py.
Also confirm the function is named exactly run_benchmarks (with an s) in benchmark.py.
help me fix my matplotlib import in visualize.py
✔️ Awesome, I've got everything!
Great. Double check you have saved visualize.py before running it.
ⓧ I'd like to double check the full code
import matplotlib.pyplot as plt
from benchmark import run_benchmarks
def create_chart():
"""Generate a comparison chart of algorithm growth curves."""
sizes, results = run_benchmarks()
plt.figure(figsize=(10, 6))
for name, times in results.items():
# Filter out None values for plotting
plot_sizes = [sizes[i] for i in range(len(times)) if times[i] is not None]
plot_times = [t for t in times if t is not None]
plt.plot(plot_sizes, plot_times, marker="o", linewidth=2, label=name)
plt.xlabel("Input Size (n)")
plt.ylabel("Time (seconds)")
plt.title("Big O in Action: Algorithm Speed vs. Input Size")
plt.legend()
plt.grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig("big_o_comparison.png", dpi=150)
print("Chart saved as big_o_comparison.png")
if __name__ == "__main__":
create_chart()
Run and interpret the chart
The script re-runs the full benchmark, so expect it to take a similar amount of time as before (bubble sort needs a moment on larger inputs).
- Generate the chart by running this command in the terminal:
python3 visualize.py
- Wait for the script to finish. You should see Chart saved as big_o_comparison.png printed in the terminal.
- Open big_o_comparison.png by clicking it in the VS Code **Explorer** sidebar.
What should I see?
Four lines with distinct shapes:
- O(1) Constant Access hugs the bottom of the chart as a flat line, nearly invisible.
- O(n) Linear Search rises in a straight diagonal.
- O(n log n) Timsort curves gently upward, staying relatively low.
- O(n^2) Bubble Sort shoots steeply upward and dominates the chart, even though it stops at 10,000 elements.
This visual hierarchy is Big O in action. The gap between the curves only grows as input size increases.
Chart looks blank or script errors out?
- If you see a ModuleNotFoundError for matplotlib, confirm you installed it with pip3 install matplotlib==3.10.9 and that you are running the script with the same python3 that pip3 is linked to.
- If the PNG file is missing, check that plt.savefig("big_o_comparison.png", dpi=150) appears inside create_chart() and not outside the function.
- If you see an empty chart with no lines, make sure the indentation of the for loop and the styling lines are all inside create_chart().
help me debug my visualize.py chart
You now have visual proof that a quadratic algorithm becomes unusable long before a linearithmic one even breaks a sweat. Next up, the Secret Mission challenges you to visualize an even more dramatic gap: exponential vs. linear growth.
Secret mission
Visualize Exponential vs. Memoized
Your Big O chart covers the common complexity classes, but there's one curve that makes all of them look flat: exponential growth. In this mission, you'll add a naive recursive Fibonacci function and prove visually how memoization tames O(2^n) down to O(n).
Clean Up Your Resources
Clean Up Your Resources
This project runs entirely locally, so there are no ongoing costs. Decide whether to keep your project files, or delete them entirely.
Resources you used:
- big-o-lab project folder (contains algorithms.py, benchmark.py, visualize.py, and generated PNG charts).
- matplotlib Python package (installed via pip3).
Keep everything running
No action needed. Choose this if you want to keep experimenting with your benchmarking tool or add more algorithms to test.
- Your big-o-lab folder stays on your Desktop with all files and charts intact.
- The matplotlib package remains installed and available for other Python projects.
Pause - I'll come back to this later
Since this project is entirely local with no running processes, there is nothing to pause. Your files will be waiting for you whenever you return.
- Your project folder and all files remain on your Desktop.
- No background processes are running that need to be stopped.
Delete - I don't want to use this again
Remove all project files and uninstall the matplotlib package to clean up completely.
- Delete the project folder by running this command in your terminal:
rm -rf ~/Desktop/big-o-lab
- Uninstall matplotlib by running:
pip3 uninstall matplotlib
- When prompted, type y and press Enter to confirm the uninstall.
Nice Work!
Nice Work!
You just built a Python benchmarking tool that measures and visualizes how algorithms perform as data grows. You now have visual proof that algorithm choice matters more than hardware.
Here's what you accomplished:
- Built four algorithms representing O(1), O(n), O(n log n), and O(n²) complexity classes.
- Created a benchmarking harness using time.perf_counter() to measure real execution times across input sizes up to 100,000 elements.
- Generated matplotlib charts that visually prove why Big O matters at scale.
- Secret Mission: Demonstrated exponential vs. linear growth using naive recursive Fibonacci and memoization to visually prove how caching drops O(2^n) down to O(n).
Ready to quiz yourself?