Tag Archives: Bubble Sort

Bubble Sort

Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order. It examines all pairs of adjacent elements, swapping them when they are out of order. Algorithm : for i in 0 .. n-2 for j in i .. n-1 if (a[j] > a[j+1]) swap(a[j], a[j+1]) We need… Read More »