Skip to content
Learnearn.uk » IGCSE Computer Science Course » Bubble Sort

Bubble Sort

Bubble Sort

Introduction to Bubble Sort

Bubble sort works by iterating through the array repeatedly, comparing adjacent elements and swapping them if they are in the wrong order.

The algorithm keeps track of the sorted partition of the array and continues sorting the remaining unsorted partition until the entire array is sorted.

This process is repeated until the array is fully sorted. It starts with the first pair of elements and continues until the last pair.

It is named as “bubble sort” because smaller elements “bubble” to the top of the list.

Demo

Example

Pros & Cons

Python Code