public static void QuickSort(int[] arrayTest, int startIndex, int endIndex) { if (startIndex >= endIndex) { return; } IndexResult result = Partition(arrayTest, startIndex, endIndex); QuickSort(arrayTest, startIndex, result.equalStartIndex - 1); QuickSort(arrayTest, result.equalEndIndex + 1, endIndex); }
public static void RandomQuickSort(int[] arrayTest, int startIndex, int endIndex) { if (startIndex >= endIndex) { return; } int randomIndex = new Random().Next(startIndex, endIndex); Exchange(ref arrayTest[randomIndex], ref arrayTest[endIndex]); IndexResult result = Partition(arrayTest, startIndex, endIndex); RandomQuickSort(arrayTest, startIndex, result.equalStartIndex - 1); RandomQuickSort(arrayTest, result.equalEndIndex + 1, endIndex); }