Compare adjacent elements and swap if out of order.
Best
O(n)
Average
O(n²)
Worst
O(n²)
Find the smallest element and place it in the correct position.
Best
O(n²)
Average
O(n²)
Worst
O(n²)
Insert each element into its correct position in the sorted part.
Best
O(n)
Average
O(n²)
Worst
O(n²)
Divide and conquer approach; recursively split and merge sorted subarrays.
Best
O(n log n)
Average
O(n log n)
Worst
O(n log n)
Divide and conquer; select a pivot, partition, and recursively sort subarrays.
Best
O(n log n)
Average
O(n log n)
Worst
O(n²)
Uses a heap data structure to repeatedly extract the maximum/minimum element.
Best
O(n log n)
Average
O(n log n)
Worst
O(n log n)
Hybrid of merge and insertion sort; optimized for real-world data.
Best
O(n)
Average
O(n log n)
Worst
O(n log n)
Hybrid of quick sort and heap sort; switches to heap sort in worst-case scenarios.
Best
O(n log n)
Average
O(n log n)
Worst
O(n log n)