Free Online Programming Tutorials

Let’s Learn Web Programming!





The bubble sort works by iterating down an array to be sorted from the first element to the last, comparing each pair of elements and switching their positions if necessary.


This process is repeated as many times as necessary, until the array is sorted.

If application that doesn’t need speed and has a relatively small amount of data to be sorted then bubble sort turns out to be really efficient.

The bubble sort gets its name from the way it works — the lighter (smaller) numbers float to the top of the list like bubbles.

Since the worst case scenario is that the array is in reverse order, and that the first element in sorted array is the last element in the starting array, the most exchanges that will be necessary is equal to the length of the array.

Add A Comment