Bubble Sort

Bubble sort is a technique has the  virtue of being very simple to implement, and as such it is an ideal place to start the investigation of sorting algorithms. In essence, the sort works by comparing neighbouring data items in an array, and if the two items are not sorted relative to each other, the two items are exchanged.

Bubble sort is a very simple sort, but has the overwhelming disadvantage of being very inefficient. This is partly due to the fact that data items move at most one location closer to their final destination with every step of the process. The item being bubbled will arrive at its destination at the end of the pass, but other items move very slowly.

Next: BS Pass 1