Skip to content

Commit 6f549d9

Browse files
author
Alison Spittel
committed
initial commit
0 parents  commit 6f549d9

4 files changed

Lines changed: 27 additions & 0 deletions

File tree

sorting/bubblesort.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Bubble Sort
2+
3+
Bubble sorting is oen of the simplest sorting algorithms. In order to implement this sort, the script starts on the left of the array and switches elements that are next to each other if they are in the wrong order. This usually requires multiple passes, unless the array is already sorted.
4+
5+
## Sample Code
6+
```python
7+
def bubble_sort(li):
8+
keep_going = False
9+
for index, (item, next_item) in enumerate(zip(li, li[1:])):
10+
if item > next_item:
11+
li[index], li[index+1] = next_item, item
12+
keep_going = True
13+
if keep_going:
14+
return bubble_sort(li)
15+
else:
16+
return li
17+
```
18+
19+
## Space Complexity: O(1)
20+
21+
## Time Complexity
22+
|Best |O(N) |
23+
|-------|------|
24+
|Average|O(N^2)|
25+
|-------|------|
26+
|Worst |O(N^2)|
27+
|-------|------|

sorting/mergesort.md

Whitespace-only changes.

sorting/quicksort.md

Whitespace-only changes.

sorting/radixsort.md

Whitespace-only changes.

0 commit comments

Comments
 (0)