DSASorting Algorithms
Sorting Algorithms Visualizer
Watch sorting algorithms in action with animated bar charts.
Select Algorithm
Bubble Sort
Repeatedly swaps adjacent elements if they are in wrong order.
O(n²)
Time
O(1)
Space
Yes
Stable
0
Comparisons
0
Swaps
default
comparing
swapping
sorted
pivot
Speed:80%
Algorithm Comparison
| Algorithm | Best | Average | Worst | Space | Stable |
|---|---|---|---|---|---|
| Bubble Sort | O(n) | O(n²) | O(n²) | O(1) | ✅ |
| Selection Sort | O(n²) | O(n²) | O(n²) | O(1) | ❌ |
| Insertion Sort | O(n) | O(n²) | O(n²) | O(1) | ✅ |
| Merge Sort | O(n log n) | O(n log n) | O(n log n) | O(n) | ✅ |
| Quick Sort | O(n log n) | O(n log n) | O(n²) | O(log n) | ❌ |
| Heap Sort | O(n log n) | O(n log n) | O(n log n) | O(1) | ❌ |