4 Commit

Autore SHA1 Messaggio Data
  Luis Jusino c6569f8eb8 2nd commit de quicksort 3 anni fa
  Luis Jusino 6f1c551ed8 1st Commit de quicksort 3 anni fa
  Luis Jusino bafdfffaec Arreglando unos conflicts 3 anni fa
  Luis Jusino 72f6eb078f 1st commit in sortingLuis 3 anni fa
1 ha cambiato i file con 19 aggiunte e 0 eliminazioni
  1. 19
    0
      sorting.py

+ 19
- 0
sorting.py Vedi File

107
 def heapSort(listaHeap):
107
 def heapSort(listaHeap):
108
 	#definan el algoritmo de ordenamiento heapsort
108
 	#definan el algoritmo de ordenamiento heapsort
109
 
109
 
110
+
110
 	for i in range(len(listaHeap) / 2, -1, -1):
111
 	for i in range(len(listaHeap) / 2, -1, -1):
111
 		heapify(listaHeap, len(listaHeap), i)
112
 		heapify(listaHeap, len(listaHeap), i)
112
 
113
 
116
 	return listaHeap
117
 	return listaHeap
117
 
118
 
118
 	return lista
119
 	return lista
120
+#Se le hace referencia y se le da credito al codigo que utilice de referencia
121
+
122
+	return lista
119
 #Se le da credito al programador de la funcion al final del codigo
123
 #Se le da credito al programador de la funcion al final del codigo
120
 
124
 
125
+
121
 def quickSort(lista):
126
 def quickSort(lista):
122
 	#definan el algoritmo de ordenamiento quicksort                        
127
 	#definan el algoritmo de ordenamiento quicksort                        
123
 	return lista
128
 	return lista
184
 	heapSort(listaHeap)				#ejecutamos el algoritmo heapSort
189
 	heapSort(listaHeap)				#ejecutamos el algoritmo heapSort
185
 	acumulaHeap+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
190
 	acumulaHeap+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
186
 
191
 
192
+
187
 	t1 = time.clock()				#seteamos el tiempo al empezar
193
 	t1 = time.clock()				#seteamos el tiempo al empezar
188
 	quickSort(listaQuick)			#ejecutamos el algoritmo quickSort
194
 	quickSort(listaQuick)			#ejecutamos el algoritmo quickSort
189
 	acumulaQuick+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
195
 	acumulaQuick+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
192
 	shellSort(listaShell)			#ejecutamos el algoritmo shellSort
198
 	shellSort(listaShell)			#ejecutamos el algoritmo shellSort
193
 	acumulaShell+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
199
 	acumulaShell+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
194
 
200
 
201
+	t1 = time.clock()                               #seteamos el tiempo al empezar
202
+	quickSort(lista)                                #ejecutamos el algoritmo quickSort
203
+	acumulaQuick+=time.clock()-t1   #acumulamos el tiempo de ejecucion
204
+	
205
+	t1 = time.clock()				#seteamos el tiempo al empezar
206
+	shellSort(lista)				#ejecutamos el algoritmo shellSort
207
+	acumulaShell+=time.clock()-t1 	#acumulamos el tiempo de ejecucion"""
208
+
209
+
195
 #imprimos los resultados
210
 #imprimos los resultados
196
 print "Promedio de tiempo de ejecucion de "+ str(veces) +" listas de largo " + str(largoLista)
211
 print "Promedio de tiempo de ejecucion de "+ str(veces) +" listas de largo " + str(largoLista)
197
 print "MergeSort " + str(acumulaMerge/veces) + " segundos"
212
 print "MergeSort " + str(acumulaMerge/veces) + " segundos"
199
 print "QuickSort " + str(acumulaQuick/veces) + " segundos"
214
 print "QuickSort " + str(acumulaQuick/veces) + " segundos"
200
 print "ShellSort " + str(acumulaShell/veces) + " segundos"
215
 print "ShellSort " + str(acumulaShell/veces) + " segundos"
201
 
216
 
217
+
218
+#Referencia:
219
+#https://stackoverflow.com/questions/18262306/quicksort-with-python
220
+