docs: add Merge Sort (#246)
parent
56d42f2287
commit
b4bbc3a68a
|
@ -1,4 +1,6 @@
|
||||||
# Algorithms
|
# Algorithms
|
||||||
|
## Sorting
|
||||||
|
- [Merge Sort](./Sorting/Merge-Sort.md)
|
||||||
|
|
||||||
## Strings
|
## Strings
|
||||||
- [Palindrome](./Strings/Palindrome.md)
|
- [Palindrome](./Strings/Palindrome.md)
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Merge Sort
|
||||||
|
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
|
||||||
|
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
|
||||||
|
Given array is
|
||||||
|
**12 11 13 5 6 7**
|
||||||
|
|
||||||
|
Sorted array is
|
||||||
|
**5 6 7 11 12 13**
|
||||||
|
|
||||||
|
## Implementation
|
||||||
|
- [Java](../../../algorithms/Java/sorting/merge-sort.java)
|
||||||
|
- [C](../../../algorithms/C/sorting/merge-sort.c)
|
||||||
|
|
||||||
|
## Video URL
|
||||||
|
[Youtube Video about Merge Sort](https://www.youtube.com/watch?v=jlHkDBEumP0)
|
||||||
|
|
||||||
|
## Others
|
||||||
|
[Wikipedia](https://en.wikipedia.org/wiki/Merge_sort)
|
Loading…
Reference in New Issue