|
@@ -10,6 +10,7 @@ from random import randint
|
10
|
10
|
import time
|
11
|
11
|
from copy import deepcopy
|
12
|
12
|
import sys
|
|
13
|
+from heapq import heapify, heappush
|
13
|
14
|
|
14
|
15
|
|
15
|
16
|
|
|
@@ -44,9 +45,38 @@ def mergeSort(lista): # Ángel G. Romero Rosario on 10082022
|
44
|
45
|
mid = len(lista) // 2
|
45
|
46
|
return merge(mergeSort(lista[:mid]), mergeSort(lista[mid:]))
|
46
|
47
|
|
47
|
|
-
|
48
|
48
|
def heapSort(lista):
|
49
|
49
|
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+ myHeap = []
|
|
54
|
+ heapify(myHeap)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+ for element in lista:
|
|
61
|
+ heappush(myHeap, -1 * element)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+ for i in range(len(myHeap)):
|
|
72
|
+ myHeap[i] = myHeap[i] * -1
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+ lista = myHeap
|
|
78
|
+ return lista
|
|
79
|
+
|
50
|
80
|
return lista
|
51
|
81
|
|
52
|
82
|
def quickSort(lista):
|
|
@@ -54,7 +84,6 @@ def quickSort(lista):
|
54
|
84
|
if(len(lista) != 0):
|
55
|
85
|
if(len(lista) == 1):
|
56
|
86
|
return lista
|
57
|
|
-
|
58
|
87
|
else:
|
59
|
88
|
p = lista[0]
|
60
|
89
|
|