Basic Sorting Complexities
Bubble Sort, Selection Sort, and Insertion Sort are elementary comparison-based algorithms. Their typical and worst-case complexities are O(n²). Insertion Sort can achieve O(n) best-case performance when the input is already sorted, while optimized Bubble Sort can also achieve O(n) best case.
Bubble Sort repeatedly swaps adjacent out-of-order elements.
Selection Sort repeatedly selects the minimum.
Insertion Sort inserts each element into the sorted prefix.
Insertion Sort is often practical for small or nearly sorted data.