quicksort.c: Don't sort the portion of the list that matches the pivot.
authorW. Trevor King <wking@drexel.edu>
Mon, 25 Oct 2010 16:54:21 +0000 (12:54 -0400)
committerW. Trevor King <wking@drexel.edu>
Mon, 25 Oct 2010 16:54:21 +0000 (12:54 -0400)
src/sorting/quicksort.c

index d763335d14e4eae72d6deb1ffc1329f1d1fbed6a..e66453f14278c3f87590448485a2d3f5d86c1331 100644 (file)
@@ -45,9 +45,9 @@ void quicksort(double list[], int m, int n)
                // put the pivot back in
                swap(&list[m], &list[j]);
 
-               // recursively sort the lesser lists
+               // recursively sort the sub-lists
                quicksort(list, m, j - 1);
-               quicksort(list, j + 1, n);
+               quicksort(list, i + 1, n);
        }
 }