def __init__(self, data, doInsertionSort=False, insertionSortThreshold=10, pivotSelection=1): ''' :param pivotSelection: Determines how the pivot should be chosen. 1 = 1st in range. 2 = last in range. 3 = median of first, middle and last in range. ''' if pivotSelection != 1 and pivotSelection != 2 and pivotSelection != 3: raise ValueError("The value of the pivot selection (%d) is invalid. Must be 1 or 2." % self.pivotSelection) BaseQuicksort.__init__(self, data, doInsertionSort, insertionSortThreshold, pivotSelection, 1)
def __init__(self, data, doInsertionSort=False, insertionSortThreshold=10, pivotSelection=1, behaveOptimally=False): ''' :param pivotSelection: This determines how pivots are chosen. There are exactly 2 valid values: 1 and 2. 1 is the default where the first and last values in the range are chosen. 2 is where tertiles are chosen. ''' if pivotSelection != 1 and pivotSelection != 2: raise ValueError("The value of the pivot selection (%d) is invalid. Must be 1 or 2." % pivotSelection) BaseQuicksort.__init__(self, data, doInsertionSort, insertionSortThreshold, pivotSelection, 2) self.__behaveOptimally = behaveOptimally
def __init__(self, data, numPivots, minHeapOptimization=False): if numPivots <= 0 or (data is not None and 2*numPivots > len(data) and 2*numPivots > MPivotQuicksort.INSERTION_SORT_THRESHOLD): raise ValueError("Invalid value for the number of pivots. Must be greater than 0 and less than half the length of the data to be sorted") BaseQuicksort.__init__(self, data, True, MPivotQuicksort.INSERTION_SORT_THRESHOLD, 1, numPivots) self.__minHeapOptimization = minHeapOptimization
def __init__(self, data): BaseQuicksort.__init__(self, data, True, YaroslavskiyQuicksort.INSERTION_SORT_THRESHOLD, 1, 2)
def __init__(self, data, insertionSortThreshold=13): BaseQuicksort.__init__(self, data, True, insertionSortThreshold, 1, 3)