Bubble Sort


Bubble Sort is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items, and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted.


Time Complexity :


Algorithm :

  1. Iterate from 0 to n-1:
  2. For each iteration, iterate from 0 to n-i-1:
  3. Compare the current element with the next element.
  4. If the current element is greater, swap them.
  5. Repeat the process until the array is sorted.

For more information, visit Wikipedia's Bubble Sort page.

Visualization