Skip to content
DSA Visualizerpreview

Bubble sort

Swap neighbours that are out of order until a pass makes no change.

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 / 29

Speed

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