Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.
Visualizing this algorithm is a great way to start
- Start iterating over the array, take two elements from the begining
- Check whether, they are in order or not. If not then swap them else leave them as they were
The complexity of bubble sort algorithms is O(n^2) in both worst and average cases.
Refer to the comments in the program and debug in your IDE for better understanding.