Introduction to bubble sort


Bubble sort, also known as sinking sort, is one of the simplest sorting algorithms that works by moving an item to its correct position by comparing it against the element that comes after it. If the element after it is smaller, it is swapped with the current element. This process is repeated until no more swaps are needed to be performed in a pass, resulting in a final sorted list.

Why is this sort called bubble sort?
This process is similar to how bubbles rise to the surface of water, where the lighter bubbles move upwards while the heavier ones sink. In Bubble sort, the smaller (or lighter) elements "bubble" to the front of the list, while the larger (or heavier) elements "sink" to the end.
Loading Image

Heavier bubble sinks down

Liking the course? Check our discounted plans to continue learning.