Welcome to Bubble-Sort

Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.

Visualization of this algorithm

Visualizing this algorithm is a great way to start Image

Working of this algorithm

  1. Start iterating over the array, take two elements from the begining
  2. Check whether, they are in order or not. If not then swap them else leave them as they were

NOTE: Repeat the above steps (n-1) times

Complexity

The complexity of bubble sort algorithms is O(n^2) in both worst and average cases.

End Notes

Refer to the comments in the program and debug in your IDE for better understanding.