Skip to content
DSA Visualizerpreview

Insertion sort

Grow a sorted prefix by inserting each value where it belongs.

O(n²) time · O(1) space

Values5, 1, 4, 2, 8, 3

Start with the array 5, 1, 4, 2, 8, 3.

Array of 6 values: 5, 1, 4, 2, 8, 3.
  • compare
  • swap or write
  • settled

1 / 30

Speed

Space play · ← → step · Home End jump · drag the strip to scrub