2 커밋

작성자 SHA1 메시지 날짜
  Ricardo A. López Torres 5f2ebfa09f documentar cambios 3 년 전
  Ricardo A. López Torres b3614865b3 crear copias de la lista original 3 년 전
1개의 변경된 파일10개의 추가작업 그리고 4개의 파일을 삭제
  1. 10
    4
      sorting.py

+ 10
- 4
sorting.py 파일 보기

38
 for i in range(veces):
38
 for i in range(veces):
39
 	lista = [randint(0,maxValor) for r in range(largoLista)] #creamos una lista con valores al azar
39
 	lista = [randint(0,maxValor) for r in range(largoLista)] #creamos una lista con valores al azar
40
 
40
 
41
+        # creamos copias de la lista para cada algoritmo
42
+        listaMerge = lista[:]
43
+        listaHeap = lista[:]
44
+        listaQuick = lista[:]
45
+        listaShell = lista[:]
46
+
41
 	t1 = time.clock() 				#seteamos el tiempo al empezar
47
 	t1 = time.clock() 				#seteamos el tiempo al empezar
42
-	mergeSort(lista) 				#ejecutamos el algoritmo mergeSort
48
+	mergeSort(listaMerge) 				#ejecutamos el algoritmo mergeSort
43
 	acumulaMerge+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
49
 	acumulaMerge+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
44
 	
50
 	
45
 	t1 = time.clock()				#seteamos el tiempo al empezar
51
 	t1 = time.clock()				#seteamos el tiempo al empezar
46
-	heapSort(lista)					#ejecutamos el algoritmo heapSort
52
+	heapSort(listaHeap)					#ejecutamos el algoritmo heapSort
47
 	acumulaHeap+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
53
 	acumulaHeap+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
48
 	
54
 	
49
 	t1 = time.clock()				#seteamos el tiempo al empezar
55
 	t1 = time.clock()				#seteamos el tiempo al empezar
50
-	quickSort(lista)				#ejecutamos el algoritmo quickSort
56
+	quickSort(listaQuick)				#ejecutamos el algoritmo quickSort
51
 	acumulaQuick+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
57
 	acumulaQuick+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
52
 	
58
 	
53
 	t1 = time.clock()				#seteamos el tiempo al empezar
59
 	t1 = time.clock()				#seteamos el tiempo al empezar
54
-	shellSort(lista)				#ejecutamos el algoritmo shellSort
60
+	shellSort(listaShell)				#ejecutamos el algoritmo shellSort
55
 	acumulaShell+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
61
 	acumulaShell+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
56
 
62
 
57
 #imprimos los resultados
63
 #imprimos los resultados