š Complexity Overview
Time and space complexity for each sorting algorithm.
ā” Performance Benchmark
Real runtime comparison at different array sizes.
Runtime Comparison
Select algorithms and click "Run Comparison" to generate chart.
š Understanding Big-O
O(1) Constant - Same time regardless of input size
O(log n) Logarithmic - Halves problem each step (Binary Search)
O(n) Linear - Grows proportionally with input
O(n log n) Linearithmic - Optimal for comparison sorts
O(n²) Quadratic - Nested loops, slow for large inputs
š” When to Use What?
Quick Sort
Best general-purpose sort. Fast in practice, but avoid for nearly-sorted data or when stability matters.
Merge Sort
Guaranteed O(n log n). Use when you need stability or consistent performance. Good for linked lists.
Heap Sort
In-place with O(n log n) worst case. Good when memory is limited and you need guaranteed performance.
Bubble Sort
Only use for teaching or tiny arrays (< 20 elements). Can be fast if data is nearly sorted.
Selection Sort
Minimizes swaps (O(n) swaps). Use only when writes are expensive and array is small.
š How Complexity Scales
Visual comparison of growth rates for different Big-O classes.