Skip to content

Add Merge Sort algo chapter and Python example #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
13 changes: 1 addition & 12 deletions chapters/sorting_searching/merge/merge_sort.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
# Merge Sort

In computer science, merge sort (also commonly spelled mergesort) is an efficient, general-purpose, comparison-based sorting algorithm.
Most implementations produce a stable sort, which means that the implementation preserves the input order of equal elements in the sorted output.
Merge sort is a divide and conquer algorithm that was invented by John von Neumann in 1945.
A detailed description and analysis of bottom-up mergesort appeared in a report by Goldstine and von Neumann as early as 1948.

Conceptually, a merge sort works as follows:
1. Divide the unsorted list into n sublists, each containing 1 element (a list of 1 element is considered sorted).
2. Repeatedly merge sublists to produce new sorted sublists until there is only 1 sublist remaining. This will be the sorted list.
# This Chapter is comming soon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"coming" is spelled with only one "m".


{% method %}
{% sample lang="py" %}
[import:1-40, lang:"python"](code/python/merge.py)
{% endmethod %}

This algorithim can be made faster by doing the merge operations in parallel.

<script>
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
</script>
Expand Down