Skip to content

Instantly share code, notes, and snippets.

@bhaveshmunot1
Created June 4, 2020 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhaveshmunot1/918a434b70e3f61c3ec8055b3c4da534 to your computer and use it in GitHub Desktop.
Save bhaveshmunot1/918a434b70e3f61c3ec8055b3c4da534 to your computer and use it in GitHub Desktop.
General Merge Sort Framework
... merge( .... ) { // O(n)
.....
}
vector<int> mergeSort(vector<int> nums) { // T(n)
.... // 1
mergeSort(leftHalf); // T(n/2)
mergeSort(rightHalf); // T(n/2)
sorted = merge(leftHalft, rightHalf); // O(n)
return sorted; // O(n)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment