This commit is contained in:
2023-09-22 09:51:10 -04:00
commit 1af8bd1e54
32 changed files with 346400 additions and 0 deletions

15
12-bubble-sort/README.md Normal file
View File

@ -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.
![bubble sort gif](http://upload.wikimedia.org/wikipedia/commons/c/c8/Bubble-sort-example-300px.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.

View File

@ -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"])