Bubble sort page

Additional details

Bubble sort is a simple 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. The algorithm gets its name from the way smaller elements "bubble" to the top of the list.

Time complexity: O(n^2) in the worst case, O(n) in the best case (when the array is already sorted).

Space complexity: O(1) as it sorts the array in place.

This implementation allows you to visualize the sorting process, control the speed of the algorithm, and adjust the size of the array being sorted.

  • Red - First index being compared
  • Light Blue - Second index being compared
  • Default - Other elements in the array