def main(): N, s = int(sys.argv[2]), sys.argv[1] Arr = Crear_arreglo_random(N) if s == "InsertionSort": inicio = time.time() Sorts.InsertionSort(Arr, N) fin = time.time() elif s == "MergeSort": inicio = time.time() Sorts.MergeSort(Arr, 0, N - 1) fin = time.time() tiempoTranscurrido = (fin - inicio) * 1000 print(s, N, tiempoTranscurrido)
import Sorts from random import randint def ArregloAleatorio(n_elementos): A = [] for i in range(0, n_elementos): A.append(randint(0, n_elementos)) return A nombre_algoritmo = sys.argv[1] n_elementos = int(sys.argv[2]) A = ArregloAleatorio(n_elementos) inicio = time.time() if (nombre_algoritmo == 'InsertionSort'): Busquedas.InsertSort(A, 0, n_elementos) fin = time.time() if (nombre_algoritmo == 'MergeSort'): Sorts.MergeSort(A, 0, n_elementos - 1) fin = time.time() tiempoTranscurrido = (fin - inicio) * 1000 print( str(nombre_algoritmo) + " " + str(n_elementos) + " " + " " + str(tiempoTranscurrido))
import Sorts import sys import time from random import randint inicio = time.time() algoritmo = str(sys.argv[1]) n = int(sys.argv[2]) i = 0 A = [] while i != n: A.append(randint(0, 1000)) i = i + 1 if algoritmo == "MergeSort": Sorts.MergeSort(A, 0, n - 1) else: Sorts.InsertionSort(A, 0, n) fin = time.time() tiempo = (fin - inicio) * 1000 print(algoritmo, n, str(tiempo))