Selaa lähdekoodia

Updated sorting.py with individual list for each algorithm.

Ernesto Ortiz 3 vuotta sitten
vanhempi
commit
141ed70d8f
1 muutettua tiedostoa jossa 9 lisäystä ja 4 poistoa
  1. 9
    4
      sorting.py

+ 9
- 4
sorting.py Näytä tiedosto

78
 for i in range(veces):
78
 for i in range(veces):
79
 	lista = [randint(0,maxValor) for r in range(largoLista)] #creamos una lista con valores al azar
79
 	lista = [randint(0,maxValor) for r in range(largoLista)] #creamos una lista con valores al azar
80
 
80
 
81
+	listaMerge = lista[:]
82
+    listaHeap = lista[:]
83
+    listaQuick = lista[:]
84
+    listaShell = lista[:]
85
+	
81
 	t1 = time.process_time()				#seteamos el tiempo al empezar
86
 	t1 = time.process_time()				#seteamos el tiempo al empezar
82
-	mergeSort(lista) 						#ejecutamos el algoritmo mergeSort
87
+	mergeSort(listaMerge) 						#ejecutamos el algoritmo mergeSort
83
 	acumulaMerge+=time.process_time()-t1 	#acumulamos el tiempo de ejecucion
88
 	acumulaMerge+=time.process_time()-t1 	#acumulamos el tiempo de ejecucion
84
 	
89
 	
85
 	t1 = time.process_time()				#seteamos el tiempo al empezar
90
 	t1 = time.process_time()				#seteamos el tiempo al empezar
86
-	heapSort(lista)							#ejecutamos el algoritmo heapSort
91
+	heapSort(listaHeap)							#ejecutamos el algoritmo heapSort
87
 	acumulaHeap+=time.process_time()-t1 	#acumulamos el tiempo de ejecucion
92
 	acumulaHeap+=time.process_time()-t1 	#acumulamos el tiempo de ejecucion
88
 	
93
 	
89
 	t1 = time.process_time()						#seteamos el tiempo al empezar
94
 	t1 = time.process_time()						#seteamos el tiempo al empezar
90
-	quickSort(lista)						#ejecutamos el algoritmo quickSort
95
+	quickSort(listaQuick)						#ejecutamos el algoritmo quickSort
91
 	acumulaQuick+=time.process_time()-t1 	#acumulamos el tiempo de ejecucion
96
 	acumulaQuick+=time.process_time()-t1 	#acumulamos el tiempo de ejecucion
92
 	
97
 	
93
 	t1 = time.process_time()				#seteamos el tiempo al empezar
98
 	t1 = time.process_time()				#seteamos el tiempo al empezar
94
-	shellSort(lista)						#ejecutamos el algoritmo shellSort
99
+	shellSort(listaShell)						#ejecutamos el algoritmo shellSort
95
 	acumulaShell+=time.process_time()-t1 	#acumulamos el tiempo de ejecucion
100
 	acumulaShell+=time.process_time()-t1 	#acumulamos el tiempo de ejecucion
96
 
101
 
97
 #imprimos los resultados
102
 #imprimos los resultados