Skip to content

Commit f8a7d5a

Browse files
committed
Adding Merge Sort algorithm desc to README
1 parent 943afbb commit f8a7d5a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ $ pip install py-algorithms
3535

3636
^ Sorting
3737
- Bubble Sort
38+
- Merge Sort
3839

3940
^ Agorithms
4041
- Quick Union
@@ -70,6 +71,28 @@ sort([20,15,0,-1,70,-88])
7071
#=> [-88, -1, 0, 15, 20, 70]
7172
```
7273

74+
#### *Merge Sort (https://en.wikipedia.org/wiki/Merge_sort)
75+
76+
In computer science, merge sort is an efficient, general-purpose,
77+
comparison-based sorting algorithm. Most implementations produce a stable sort,
78+
which means that the implementation preserves the input order of equal elements in the sorted output.
79+
Mergesort is a divide and conquer algorithm that was invented by John von Neumann in 1945.
80+
81+
Worst case: О(n)
82+
Best case: О(n log n)
83+
Average: О(n log n)
84+
Worst case space: O(n)
85+
86+
```python
87+
from py_algorithms.sort import new_merge_sort
88+
89+
xs = [0, 6, 7, 8, 9, 4, 5, 12, -1]
90+
sorting_algorithm = new_merge_sort()
91+
sorting_algorithm(xs)
92+
93+
#=> [-1, 0, 4, 5, 6, 7, 8, 9, 12]
94+
```
95+
7396
---
7497

7598
### Search Algorithms

0 commit comments

Comments
 (0)