I am trying to perform quicksort using C++ library partition function, Here's my code
int p;
int pred(int x)
{
return x<=p;
}
void quickSort(vector<int>::iterator first,vector<int>::iterator last) {
if(first == last)
return;
if((first+1) == last)
return;
p = *first;
auto mid = partition(first,last,pred);
quickSort(first,mid);
quickSort(mid,last);
--mid;
swap(*mid,*first);
for(auto itr = first;itr!=last;++itr)
cout<<(*itr)<<" ";
cout<<endl;
}
It gives segFault in the partition function. I want to use the library function.