Skip to content

Instantly share code, notes, and snippets.

@maxfunke
Created May 23, 2014 09:31
Show Gist options
  • Save maxfunke/ca9c54fd449ce543e9b2 to your computer and use it in GitHub Desktop.
Save maxfunke/ca9c54fd449ce543e9b2 to your computer and use it in GitHub Desktop.
Recursive MergeSort Algorithm
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