stuff
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
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.
|
||||
@@ -0,0 +1,8 @@
|
||||
def bubble_sort(list):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
assert bubble_sort([5,19,4,1,36,99,2]) == sorted([5,19,4,1,36,99,2])
|
||||
assert bubble_sort(["Greg", "Armen", "Ken"]) == sorted(["Greg", "Armen", "Ken"])
|
||||
Reference in New Issue
Block a user