void merge(vector<int> dst,vector<int> first,vector<int> second)
{
int i=0,j=0;
while(i<first.size()&&j<second.size())
{
if(first[i]<second[j])
{
dst.push_back(first[i]);
i++;
}
else
{
dst.push_back(second[j]);
j++;
}
}
while(i<first.size()
dst.push_back(first[i++]);
while(j<second.size())
dst.push_back(second[j++]);
}
void mergeSort(vector<int> &a)
{
size_t sz = a.size();
cin.get();
if(sz>1)
{
vector<int> first(&a[0],&a[sz/2]);
vector<int> second(&a[(sz/2)+1],&a[sz-1]);
mergeSort(first);
mergeSort(second);
merge(a,first,second);
}
}
void MergeSort(int* a,size_t size)
{
vector<int> s(&a[0],&a[size-1]);
mergeSort(s);
}
Can some one help me what is the problem with this code ? I am getting vector subscript outof range error.