# Para retornar los indices l,m en la funcion partition_with_pivot, # utilice 'return l, m' # Para recibir los indices l,m en la llama da partition_function en la # funcion quicksort_rec, utilice 'l, m = partition_function(A, p, r)' ######################################################################## # leer los datos y preparar variables para correr experimentos data = read_file('data/web2') sizes = [2**i for i in range(16)] fractions = [.5, .05, .005, .0005] runs_for_each_size_and_fraction = 10 # imprimir encabezado de resultados print 'type,name,size,i,time,verification' # experimentos para algoritmos de ordenamiento test_sort('nativo', sizes, fractions, data, runs_for_each_size_and_fraction, native_sort, verifier_sort) test_sort('mergesort', sizes, fractions, data, runs_for_each_size_and_fraction, mergesort, verifier_sort) test_sort('heapsort', sizes, fractions, data, runs_for_each_size_and_fraction, heapsort, verifier_sort) test_sort('quicksort', sizes, fractions, data, runs_for_each_size_and_fraction, quicksort, verifier_sort) test_sort('quicksort-randomizado', sizes, fractions, data, runs_for_each_size_and_fraction, quicksort_randomized, verifier_sort)
i = j - 1 while i >= start and A[i] > key: A[i + 1] = A[i] i = i - 1 A[i + 1] = key return A ######################################################################## # leer los datos y preparar variables para correr experimentos data = read_file('./data/english.txt') sizes = [2**i for i in range(16)] runs_per_each_size = 10 fractions = [.5, .05, .005, .0005] runs_per_each_size_and_fraction = 3 # imprimir encabezado de resultados print 'type,name,size,i,time,verification' # experimentos para algoritmos de busqueda en arreglos test_search('linear', sizes, data, runs_per_each_size, linear_search, verifier_linear_search, False) test_search('binary', sizes, data, runs_per_each_size, binary_search, verifier_binary_search, True) # experimentos para algoritmos de ordenamiento test_sort('native', sizes, fractions, data, runs_per_each_size_and_fraction, native_sort, verifier_sort) test_sort('insertion', sizes[:-1], fractions, data, runs_per_each_size_and_fraction, insertion_sort, verifier_sort)