How does Bubble sort works?
Bubble sort is a comparison based sorting algorithm. It works like following. We perform series of iterations to ‘bubble up’ the elements one by one so that they form a sorted order. For example we have to sort an array [3,1,4,5,2] in ascending order, In the first iteration, the element 5 will be bubbled up…