Hello! so, I'm implementing quicksort and selection sort using vectors.
I have the following code. To run I use redirection. i.e. ./program.out <datafile
Code:
int main()
{
int number;
vector<int> list;
cout << "QuickSort..." << endl;
while (cin >> number)
{
list.push_back(number);
}
int left = 0;
int size = list.size();
int right = size-1;
print(list); // testing sort
quickSort(list, left, right);
print(list); // testing sort
cout << "Done" << endl;
return 0;
}
But my vector seems to be empty?
I've changed the while loop to
Code:
cin >> number;
while (!cin.eof())
{
list.push_back(number);
cin >> number;
}
That gives me a bad_alloc error though.
Any tips? My sorts work with small sets, but I haven't been able to test larger 2000 and above sets yet because of this. :(