Commit af6014b3 authored by ShahRukh's avatar ShahRukh

update merge-sort to reflect API update

parent 9e7f74fa
......@@ -57,8 +57,29 @@ vector<int> mergeSorting(vector<int> v){
vector<int> sort_custom(vector<int> v){
vector<int> sortVec = mergeSorting(v);
return sortVec;
vector<int> sort_custom(vector<int> v , int startidx, int endidx){
int size = v.size();
if (size < endidx || startidx > endidx) {
cout << "Invalid Input ";
vector<int> v;
return v;
else {
vector<int> initVector(v.cbegin(), v.cbegin()+startidx);
vector<int> subVector(v.cbegin()+startidx, v.cbegin()+endidx+1);
vector<int> endVector(v.cbegin()+endidx+1, v.cend());
vector<int> sortVec = mergeSorting(subVector);
initVector.insert( initVector.end(), sortVec.begin(), sortVec.end() );
initVector.insert( initVector.end(), endVector.begin(), endVector.end() );
return initVector;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment