def main(arguments): SortingUtilClass.print_title(4, 'Quick Sort') s = SortingClass() func = arguments.algorithm if func == 'bubble': array = copy(a) s.bubble_sort(array).finish() elif func == 'insertion': array = copy(a) s.insertion_sort(array).finish() elif func == 'selection': array = copy(a) s.selection_sort(array).finish() elif func == 'quick': array = copy(a) s.quick_sort(array, 0, len(array) - 1).finish() elif func == 'heap': array = copy(a) print(array) s.heap_sort(array, len(array)).finish() print(array) elif func == 'all': array = copy(a) s.all(array) else: array = copy(a) s.quick_sort(array, 0, len(array) - 1).finish() sys.exit(0)
def insertion(size): array = sample(range(size), size) s = SortingClass(to_print=False) analysis = s.insertion_sort(array).get_analysis() comparisons = analysis['comparisons'] return comparisons