Bubble Sort Algorithm

By Matthew Chang 9/8

What is Bubble Sort?

Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the input list element by element, comparing the current element with the one after it, swapping their values if needed. These passes through the list are repeated until no swaps had to be performed during a pass, meaning that the list has become fully sorted.

Algorithm

  • Compare the values of the first element of the list with the next element, swap the elements depending on how the list is to be sorted.
  • Compare the next element and its succeeding element, repeat process until the last element is compared.
  • Repeat this process from the start untill no more swapping is requred.
  • Bubble Sort, taken from Programiz.