- Bubble sort compares adjacent elements and swaps them if they are in the wrong order.
- Bubble sort repeatedly passes through the list until no swaps are needed.
- Time complexity of bubble sort is O(n2).
- Selection sort divides the list into a sorted and an unsorted region.
- Selection sort finds the smallest element in the unsorted region and swaps it with the leftmost unsorted element.
- Time complexity of selection sort is O(n2).
- Insertion sort builds a sorted list one element at a time by repeatedly inserting the next element into its proper position.
- Time complexity of insertion sort is O(n2).
- Merge sort divides the list into smaller sublists, sorts them recursively, and then merges them back together.
- Time complexity of merge sort is O(n log log n).
- Quick sort divides the list into two partitions based on a pivot element, then recursively sorts the partitions.
- Time complexity of quick sort is O(n log log n) on average, but worst-case time complexity is O(n2).