Working of Bubble Sort
So, we suppose we are trying to sort the elements of an Array in Ascending Order.
- In this, we start with the first element.
- Compare the element with the next element of the array.
- If the current element is greater than the next element, then we swap both the elements.
- If not, we move on to the next element of the array and check if this element is greater than the next one.
- So, We repeat Steps 2-4 until we get a sorted array in Ascending Order as in this case.
8
