# | Aspect | Bubble Sort | Selection Sort | Insertion Sort |
---|---|---|---|---|
1 | Best Case | O(n) → Fast if array is already sorted | O(n²) → No improvement in best case | O(n) → Very efficient when array is nearly sorted |
2 | Average Case | Θ(n²) | Θ(n²) | Θ(n²) |
3 | Worst Case | Θ(n²) | Θ(n²) | Θ(n²) |
3 | Stability | Stable → Equal elements keep order | Not Stable → Equal elements may swap order | Stable → Equal elements keep order |
4 | Adaptive | Yes (Improves if list nearly sorted) | No | Yes (Efficient for partially sorted data) |
5 | Swaps | Many → Makes it slow | Few → Makes it faster | Moderate → Balanced performance |
6 | Comparisons | High → Slower | High → Slower | Less in sorted lists → Faster |
7 | Practical Use | Rarely used (too slow) | Useful for small datasets | Good for small or nearly sorted datasets |
8 | Overall Efficiency | Poor → Slow in most cases | Better than Bubble but still slow | Best among the three for small/nearly sorted data |
O(n²)
.O(n)
instead of O(n²)
.Key Reason: Insertion Sort is adaptive, has less overhead, and runs very fast on small or nearly sorted datasets, making it better than Bubble or Selection Sort in such cases.
Your feedback helps us grow! If there's anything we can fix or improve, please let us know.
We’re here to make our tutorials better based on your thoughts and suggestions.