Bubble sort is a comparative sort in which we compare an element with its adjacent element, if second element is smaller than the first one then those element will be interchanged. Now again element is selected and compared with its adjacent. This process will be continued untill the highest element will reach at the last position.
Bubble_Sort (a, n) Begin for k=1 to n-1 for j=0 to n-k-1 if a[j] > a[j+1] then Set temp = a[j]; Set a[j] = a[j+1]; Set a[j+1] = temp; endif endfor endfor End
Best Case: O(n)
Average Case: O(n2)
Worst Case: O(n2)