Browse Source

Sorting file Diego_8:50pm

Diego 3 years ago
parent
commit
54210bef9f
1 changed files with 16 additions and 8 deletions
  1. 16
    8
      sorting.py

+ 16
- 8
sorting.py View File

1
 #coding=utf-8
1
 #coding=utf-8
2
 
2
 
3
 """
3
 """
4
-Programadores:
5
 
4
 
5
+Grupo: JoJaJuDie == *ACUERDENSE DE PONER SUS NOMBRES COMPLETOS*
6
+Diego A. Rodriguez Agueros
7
+Javier
8
+Luis Jusino
9
+Joel
10
+
11
+*Referencias incluidas al final del códogo*
6
 """
12
 """
7
 
13
 
8
 """
14
 """
22
 
28
 
23
 	return lista
29
 	return lista
24
 
30
 
25
-#===============================
26
-#Modificación a código: Diego
27
-#Añado función heapify
28
-#===============================
31
+# Credito de esta función incluida al final del código
29
 def heapify(listaHeap, largoLista, i):
32
 def heapify(listaHeap, largoLista, i):
30
 	largest = i
33
 	largest = i
31
 	left = 2 * i + 1
34
 	left = 2 * i + 1
40
 	if largest != i:
43
 	if largest != i:
41
 		listaHeap[i], listaHeap[largest] = listaHeap[largest], listaHeap[i]
44
 		listaHeap[i], listaHeap[largest] = listaHeap[largest], listaHeap[i]
42
 		heapify(listaHeap, largoLista, largest)
45
 		heapify(listaHeap, largoLista, largest)
43
-#Fin de función heapify
44
-#===============================
45
 
46
 
47
+# Credito de esta función incluida al final del código
46
 def heapSort(listaHeap):
48
 def heapSort(listaHeap):
47
 	#definan el algoritmo de ordenamiento heapsort
49
 	#definan el algoritmo de ordenamiento heapsort
48
-
49
 	for i in range(len(listaHeap) / 2, -1, -1):
50
 	for i in range(len(listaHeap) / 2, -1, -1):
50
 		heapify(listaHeap, len(listaHeap), i)
51
 		heapify(listaHeap, len(listaHeap), i)
51
 
52
 
102
 print "HeapSort " + str(acumulaHeap/veces) + " segundos"
103
 print "HeapSort " + str(acumulaHeap/veces) + " segundos"
103
 print "QuickSort " + str(acumulaQuick/veces) + " segundos"
104
 print "QuickSort " + str(acumulaQuick/veces) + " segundos"
104
 print "ShellSort " + str(acumulaShell/veces) + " segundos"
105
 print "ShellSort " + str(acumulaShell/veces) + " segundos"
106
+
107
+"""
108
+Referencias:
109
+https://www.geeksforgeeks.org/heap-sort/
110
+https://www.programiz.com/dsa/heap-sort
111
+
112
+"""