week2/12-bubble-sort
2023-09-22 09:51:10 -04:00
..
2023-09-22 09:51:10 -04:00
2023-09-22 09:51:10 -04:00

Bubble Sort

Wikipedia on bubble sort.

Algorithm

A bubble sort is a sorting algorithm with a Big O complexity of O(n**2). It is called bubble sort, because the small numbers "bubble" to the top of the list.
bubble sort gif

The general flow is to step through the list, continually comparing pairs of numbers. If the number on the left is larger than the number on the right, swap them and continue.

Implementation

Write a function, bubble_sort(), that takes an list. It should return a sorted list, using the bubble sort algorithm.