|
@@ -1,8 +1,14 @@
|
1
|
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,10 +28,7 @@ def mergeSort(listaMerge):
|
22
|
28
|
|
23
|
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
|
32
|
def heapify(listaHeap, largoLista, i):
|
30
|
33
|
largest = i
|
31
|
34
|
left = 2 * i + 1
|
|
@@ -40,12 +43,10 @@ def heapify(listaHeap, largoLista, i):
|
40
|
43
|
if largest != i:
|
41
|
44
|
listaHeap[i], listaHeap[largest] = listaHeap[largest], listaHeap[i]
|
42
|
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
|
48
|
def heapSort(listaHeap):
|
47
|
49
|
#definan el algoritmo de ordenamiento heapsort
|
48
|
|
-
|
49
|
50
|
for i in range(len(listaHeap) / 2, -1, -1):
|
50
|
51
|
heapify(listaHeap, len(listaHeap), i)
|
51
|
52
|
|
|
@@ -102,3 +103,10 @@ print "MergeSort " + str(acumulaMerge/veces) + " segundos"
|
102
|
103
|
print "HeapSort " + str(acumulaHeap/veces) + " segundos"
|
103
|
104
|
print "QuickSort " + str(acumulaQuick/veces) + " segundos"
|
104
|
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
|
+"""
|