AlgoFrames

Elementary sorting

Simple quadratic sorts that show how comparisons and swaps put data in order.

  • Bubble sort Bubble sort compares neighbours and swaps them when out of order, so the largest values bubble to the end. The sorted suffix grows by one…
  • Selection sort Selection sort scans for the smallest remaining value and swaps it into place, one swap per pass. It always takes O(n²) comparisons.
  • Insertion sort Insertion sort lifts each element out and slides it left into the sorted prefix. It is fast on nearly sorted data.