🔢 Sorting Algorithms — Index
Parent: Array Index
| Algorithm | Time (Avg) | Space | Stable | When to Use |
|---|---|---|---|---|
| Bubble Sort | O(n²) | O(1) | ✅ | Teaching only |
| Selection Sort | O(n²) | O(1) | ❌ | Swaps are costly |
| Insertion Sort | O(n) best | O(1) | ✅ | Nearly sorted, small arrays |
| Merge Sort | O(n log n) | O(n) | ✅ | Stable large-scale, linked lists |
| Quick Sort | O(n log n) | O(log n) | ❌ | General purpose, fast |
| Heap Sort | O(n log n) | O(1) | ❌ | Memory limited |
| Counting Sort | O(n+k) | O(k) | ✅ | Integer range 0–100 |
| Radix Sort | O(d×n+k) | O(n+k) | ✅ | Large integers, IDs |
| Bucket Sort | O(n+k) avg | O(n+k) | ✅ | Uniform floats |