AlgoFrames

State after one pass

Warm-up · Trace the algorithm · about 3 min

Bubble sort runs on [6, 2, 7, 3, 5]. Arrange the bars as they stand after the first pass.

Example 1

Input:

{"values":[6,2,7,3,5]}

Output:

[2,6,3,5,7]

Constraints

  • The trace uses the input shown.
  • One pass compares each neighbouring pair once, left to right.

Learn the idea first: Bubble sort, a visual lesson.

More Bubble sort problems