4.1

Sorting Algorithms

Compare and visualize how different sorting algorithms rearrange data, step by step. Watch the tradeoffs between time complexity, space usage, and stability unfold in real time.

Prerequisite: Arrays & Basic Loops
Array Size30
Bubble Sort
Avg: O(n²)Space: O(1)STABLE
Comparisons0
Swaps0
Accesses0
Unsorted
Comparing
Swapping
Pivot
Sorted
1.0x
Complexity Comparison
AlgorithmBestAverageWorstSpaceStable
Bubble Sort
O(n)O(n²)O(n²)O(1)Yes
Selection Sort
O(n²)O(n²)O(n²)O(1)No
Insertion Sort
O(n)O(n²)O(n²)O(1)Yes
Merge Sort
O(n log n)O(n log n)O(n log n)O(n)Yes
Quick Sort
O(n log n)O(n log n)O(n²)O(log n)No
Heap Sort
O(n log n)O(n log n)O(n log n)O(1)No