Summary

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