Created
May 23, 2014 09:31
-
-
Save maxfunke/ca9c54fd449ce543e9b2 to your computer and use it in GitHub Desktop.
Recursive MergeSort Algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void MergeSort(Vector<int> &v){ | |
if (v.size() > 1) { | |
int n1 = v.size()/2; | |
int n2 = v.size() - n1; | |
Vector<int> left = Copy(v, 0, n1); Vector<int> right = Copy(v, n1, n2); MergeSort(left); | |
MergeSort(right); | |
Merge(v, left, right); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment