Bubble Sort
Worst Case: O(n^2)
Best Case: O(n)
Insertion Sort
Worst Case: O(n^2)
Best Case: O(n)
Selection Sort
Worst Case & Best Case: O(n^2)
Quick Sort
Worst Case: O(n^2)
Average & Best: O(n log n)
The “Divide and Conquer” Algorithm
Heap Sort
Worst/Average/Best Case: O(n log n)
WHY (n log n)?
–> Creation of the heap is O(n log n).
–> Popping items is O(1),
- Fixing the heap after the pop is O(log n),
- AND there are n pops
- So there is another O(n log n) factor.
Thus, O(n log n) overall.
Counting Sort
Worst/Average/Best Case: O(n)
O(n) since every step is O(n).