Introduction to Bubble Sort

Bubble sort sorts an array, by swapping elements that are in the wrong order.

We'll cover the following...

The algorithm starts with the first element in the array until the last element in the array, and keeps on doing so until there is one complete pass without swapping! This creates a “bubble” effect, hence the name.

We want the array [4, 2, 1, 3] to be sorted in ascending order.

  1. We go to the first element in the array, which is ...