Master the art of organizing data efficiently. From simple comparison-based sorts to advanced non-comparison algorithms, learn how different sorting techniques work and when to use them.
Algorithms that sort by comparing elements with each other
Algorithms that sort without direct element comparisons
Algorithms that combine multiple sorting strategies
Case | Bubble | Selection | Insertion | Merge | Quick | Heap |
---|---|---|---|---|---|---|
Best Case | O(n) | O(n²) | O(n) | O(n log n) | O(n log n) | O(n log n) |
Average Case | O(n²) | O(n²) | O(n²) | O(n log n) | O(n log n) | O(n log n) |
Worst Case | O(n²) | O(n²) | O(n²) | O(n log n) | O(n²) | O(n log n) |
Use Insertion Sort - Simple, efficient for small arrays, adaptive
Use Quick Sort or Merge Sort - Excellent average performance
Use Merge Sort or Heap Sort - No worst-case scenarios
Use Counting Sort or Radix Sort - Linear time complexity
Use Merge Sort, Insertion Sort, or counting-based sorts
Use Quick Sort or Heap Sort - In-place sorting
Try our interactive sorting visualizer to see algorithms in action