Bubble Sort

Bubble Sort is a simple comparison-based sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted.

Steps:

  1. Compare adjacent elements and swap if they are in the wrong order
  2. After each iteration, the largest element bubbles up to the end
  3. Repeat for all elements until no swaps are needed

Time Complexity

Best: O(n)

Average: O(n²)

Worst: O(n²)

Space Complexity

O(1)

Array length:

7

Speed:

Canvas is not supported in your browser. Please use Edge or Chrome.