Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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 selection(size):
	array = sample(range(size), size)
	s = SortingClass(to_print=False)
	analysis = s.selection_sort(array).get_analysis()
	comparisons = analysis['comparisons']
	return comparisons
Exemplo n.º 4
0
def selection(size):
    array = sample(range(size), size)
    s = SortingClass(to_print=False)
    analysis = s.selection_sort(array).get_analysis()
    comparisons = analysis['comparisons']
    return comparisons