I'm trying to debug an implementation of Quicksort using a singly-linked list. I keep getting a seg fault right after running the program, which indicates that it lies somewhere early on in the sorting process. Any guesses?
I know, it's not ideal at all to use Quicksort as opposed to, say Mergesort. But this is for a class, and we have to implement quicksort using a singly-linked list.
You can assume several things. *operator has been overloaded for this class type's iterator object and returns the value pointed to by the iterator. (*before)() has been passed an appropriate before() function that returns true or false depending on the desired comparison.
the size() member function uses a for loop to count the current size of the list. And the =operator has been overloaded so that it assigns one list to another, and clears the other list.
Nothing stands out.. Though this is not a good method of debugging. Just litter your code with cout<<s until you know which line is the last one executed and what are the values of your variables at that point. That is, assuming that you can't use a debugger..