Here's how I generate the numbers to be sorted.
vector<int> list;
for (i=0;i<50;i++) list.push_back(rand() %1000);
Here is my call in main
quickSort(list , 0, (list.size() -1 ));
here's the quicksort function
int pivot = left;
int temp = right;
if(left > right - 1)
return;
while (left != right) {
if (pivot == left){
if (list[pivot] > list[right]) {
//-------------------------
std:swap(list, right, pivot);
//-------------------------
pivot = right;
left++;
}else{
right--;
}
}else{
if (list[pivot] < list[left]) {
//-------------------------
swap(list, left, pivot);
//-------------------------
pivot = left;
right--;
}else{
left++;
}
}
}
quickSort(list, 0, right -1);
quickSort(list, right + 1, temp);
As the number of elements I'm sorting gets closer to about 50 the time it takes to sort get exponentially larger. I'm out of ideas. Anyone ever dealt with this before?