Saltar al contenido

Lesson 72: Insertion sort

English

Sort like playing cards

  • An insertion sort builds a sorted part on the left, one item at a time.
  • Take the next item, keep it in temp, move the items before it to the right while they are smaller, and put temp in the gap.
  • Bubble sort (lesson 46) swaps neighbours again and again; insertion sort slides each item straight into place.

Iniciar sesión o crear cuenta

IGCSE, A-Level & AP