2021-04-24 23:39:38 +00:00
# Merge Sort
2021-06-08 10:41:29 +00:00
2021-04-24 23:39:38 +00:00
Merge Sort is a Divide and Conquer algorithm. It divides the input array into two halves, calls itself for the two halves, and then merges the two sorted halves.
## Steps
2021-06-08 10:41:29 +00:00
2021-04-24 23:39:38 +00:00
1. Find the middle point to divide the array into two halves.
2. Call mergeSort for first half.
3. Call mergeSort for second half.
4. Merge the two halves sorted in step 2 and 3.
## Example
2021-06-08 10:41:29 +00:00
Given array is
**12 11 13 5 6 7**
Sorted array is
2021-04-24 23:39:38 +00:00
**5 6 7 11 12 13**
## Implementation
2021-06-08 10:41:29 +00:00
2021-04-24 23:39:38 +00:00
- [Java ](../../../algorithms/Java/sorting/merge-sort.java )
- [C ](../../../algorithms/C/sorting/merge-sort.c )
2021-06-08 10:41:29 +00:00
- [C++ ](../../../algorithms/CPlusPlus/Sorting/merge-sort.cpp )
- [JavaScript ](../../../algorithms/JavaScript/src/sorting/merge-sort.js )
- [Python ](../../../algorithms/Python/sorting/merge_sort.py )
2021-09-26 14:45:46 +00:00
- [C# ](../../../algorithms/CSharp/src/Sorts/merge-sort.cs )
2021-04-24 23:39:38 +00:00
## Video URL
2021-06-08 10:41:29 +00:00
[Youtube Video about Merge Sort ](https://www.youtube.com/watch?v=jlHkDBEumP0 )
2021-04-24 23:39:38 +00:00
## Others
2021-06-08 10:41:29 +00:00
2021-04-24 23:39:38 +00:00
[Wikipedia ](https://en.wikipedia.org/wiki/Merge_sort )