2014-02-16

I have to run various versions of the quicksort, counting sort and bubble sort algorithms on a bunch of data files containing unsorted numbers to log the time the algorithm takes on different data sets, and I want to do a script so I don't have to manually run them for each file (I have a lot).

When I run the various algorithms by themselves, calling them manually in the console with Python "algorithmname".py -f "testfilepath", everything works fine. Unfortunately, when I run my script to run them one after each other on each test files, I am having problems with the 4 quicksort versions I have implemented. Each and everytime I run my script to run the algorithms one after another, I get the following error: RuntimeError: Maximum recursion depth exceeded in comparison.

Here is how I call the algorithms one after another in my script file:

In the main function of the quicksort algorithms, I just call the quick() function, which is the function that implements the quicksort algorithm, with the good parameters. Here is an example:

And here is my quicksort implementation:

medianIndex() is just a function that will find the index of the median number between the first, middle and last element of the list.

The console tells me that the error happens for the line

but I can't find out why it gives me that error when I run the script that just runs every algorithms one after another but not when I run the separately.

Thanks for your help.

EDIT:
As demanded, here is the medianIndex() function and the med3() function it internally uses:

Show more