16 lines
696 B
Markdown
16 lines
696 B
Markdown
Bubble Sort
|
|
===========
|
|
|
|
Wikipedia on [bubble sort](http://en.wikipedia.org/wiki/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.
|
|

|
|
|
|
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.
|