Tip

Rather than memorizing the procedures, I find it more helpful to imagine myself sorting an object with my hand using a specific algorithm.

I recommend https://visualgo.net/en/sorting for visualizing sorting algorithms.

  • Selection Sort: Move minimum of unsorted subarray into correct position in the sorted subarray.
  • Insertion Sort: Move unsorted element into correct position in the sorted subarray.
  • Merge Sort:
    1. Split array into small (length2) subarrays.
    2. Sort all subarrays.
    3. Merge all subarrays into a sorted array.
  • Quick Sort:
    1. Pick a pivot element.
    2. Make array so elements “left” of pivot is smaller than pivot, and elements “right” of pivot is larger.
    3. Recursively call quicksort on “left” and “right”.
  • Bucket Sort: Use “buckets” - An array of lists. Assign each element in to 1 bucket, usually by its value (or function of).
  • Counting Sort: Get counts for all unique elements, then sort array using the counts.