Sorting Algorithms
A comprehensive overview of sorting algorithms, their time complexity, and use cases
Introduction
Sorting algorithms arrange data in a specific order for efficient access and processing. Each algorithm has different time complexities and is suitable for different scenarios.
Algorithm Comparison
This table is a quick reference for selecting the right algorithm. For more detailed analysis, please refer to the individual algorithm pages.
Prop | Type | Default |
---|---|---|
Radix Sort? | O(nk) | Stable, O(n+k) space |
Quick Sort? | O(n log n) | Unstable, In-place |
Merge Sort? | O(n log n) | Stable, O(n) space |
Shell Sort? | O(n^1.3) | Unstable, In-place |
Count Sort? | O(n+k) | Stable, O(k) space |
Cyclic Sort? | O(n) | Unstable, In-place |
Insertion Sort? | O(n²) | Stable, In-place |
Selection Sort? | O(n²) | Unstable, In-place |
Bubble Sort? | O(n²) | Stable, In-place |
Quick Selection Guide
Prop | Type | Default |
---|---|---|
Nearly Sorted Data? | Insertion Sort | O(n) best case |
Limited Integer Range? | Count Sort | O(n+k) complexity |
Integer Range [1,n]? | Cyclic Sort | O(n) time, O(1) space |
Memory Constrained? | Quick Sort | O(log n) space |
Stability Required? | Merge Sort | O(n) extra space |
Large Dataset (> 1000)? | Quick Sort | O(n log n) average |
Medium Dataset (50-1000)? | Shell Sort | O(n^1.3) average |
Small Dataset (< 50)? | Insertion Sort | O(n²) worst case |
How is this guide?