Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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