Big O Algo Racer

Big O Notation Visualizer & Algorithm Racing Game | iTechVista
Dark Light

Algorithm Controls

100
Small (10-50) vs Large (200-500) shows dramatic difference
50
0ms = Fastest, 200ms = Slow motion for learning

Algorithm Race Track

0.00s
Bubble Sort - "The Brute Force"
O(n²)
Quick Sort - "The Optimizer"
O(n log n)

Bubble Sort Stats

Comparisons: 0
Swaps: 0
Time: 0.00s
Status: Ready

Quick Sort Stats

Comparisons: 0
Swaps: 0
Time: 0.00s
Status: Ready

📊 Understanding Time Complexity & Big O Notation

Big O Notation is a mathematical concept that describes how the runtime or space requirements of an algorithm grow as the input size increases. It's the language we use to talk about algorithm efficiency.

Algorithm Comparison

Bubble Sort - O(n²)

Repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. Simple but inefficient for large datasets.

Quick Sort - O(n log n)

Divides the array into smaller sub-arrays around a pivot element, then recursively sorts the sub-arrays. Much more efficient for large datasets.

Why it matters: For 1000 items, Bubble Sort could take ~1,000,000 operations while Quick Sort only needs ~10,000 operations. That's 100x faster!

O(1) - Constant Time

Accessing an array element by index. Time doesn't change with input size. Example: array[42]

O(n) - Linear Time

Simple loop through an array. Time grows linearly with input size. Example: Finding max value in unsorted array.

O(n²) - Quadratic Time

Nested loops (like Bubble Sort). Time grows with the square of input size. Example: Checking all pairs in an array.

O(n log n) - Linearithmic Time

Efficient sorts (like Quick Sort, Merge Sort). Much faster than O(n²) for large data. Example: Divide and conquer algorithms.

Real-world analogy: If you have 10 books to sort, either method works fine. But if you have 10,000 books, Bubble Sort would take hours while Quick Sort finishes in seconds!

🏁 Race Complete!
Both algorithms have finished sorting the array.