Bubble sort explained with simple example
Bubble sort is one of the simplest sorting algorithm which traverse through the list, compares items at adjacent places, and swaps them to make list sorted. After every pass of list one or more item is placed at its correct position. If in a pass, no swaps are performed then it means list becomes sorted.
Pros:
1) Simple algorithm.
2) No extra memory needed.
3) Good for cases when list is almost sorted (only few misplaced items).
Cons:
1) Very slow algorithm. Not good for very large set of data.