|
@@ -0,0 +1,181 @@
|
|
1
|
+[
|
|
2
|
+ {
|
|
3
|
+ "label": "time",
|
|
4
|
+ "kind": 6,
|
|
5
|
+ "isExtraImport": true,
|
|
6
|
+ "importPath": "time",
|
|
7
|
+ "description": "time",
|
|
8
|
+ "detail": "time",
|
|
9
|
+ "documentation": {}
|
|
10
|
+ },
|
|
11
|
+ {
|
|
12
|
+ "label": "randint",
|
|
13
|
+ "importPath": "random",
|
|
14
|
+ "description": "random",
|
|
15
|
+ "isExtraImport": true,
|
|
16
|
+ "detail": "random",
|
|
17
|
+ "documentation": {}
|
|
18
|
+ },
|
|
19
|
+ {
|
|
20
|
+ "label": "heap",
|
|
21
|
+ "kind": 6,
|
|
22
|
+ "isExtraImport": true,
|
|
23
|
+ "importPath": "heap",
|
|
24
|
+ "description": "heap",
|
|
25
|
+ "detail": "heap",
|
|
26
|
+ "documentation": {}
|
|
27
|
+ },
|
|
28
|
+ {
|
|
29
|
+ "label": "heapify",
|
|
30
|
+ "kind": 2,
|
|
31
|
+ "importPath": "heap",
|
|
32
|
+ "description": "heap",
|
|
33
|
+ "peekOfCode": "def heapify(lista, n, i):\n\t\t# largest is root for now\n\t\tlargest = i\n\t\t# left child of root\n\t\tleft = 2 * i + 1\n\t\t# right child of root\n\t\tright = 2 * i + 2\n\t\t# Checks if root has a left child and is greater\n\t\t# than root\n\t\tif l < n and lista[i] < lista[l] :",
|
|
34
|
+ "detail": "heap",
|
|
35
|
+ "documentation": {}
|
|
36
|
+ },
|
|
37
|
+ {
|
|
38
|
+ "label": "\t\tlargest",
|
|
39
|
+ "kind": 5,
|
|
40
|
+ "importPath": "heap",
|
|
41
|
+ "description": "heap",
|
|
42
|
+ "peekOfCode": "\t\tlargest = i\n\t\t# left child of root\n\t\tleft = 2 * i + 1\n\t\t# right child of root\n\t\tright = 2 * i + 2\n\t\t# Checks if root has a left child and is greater\n\t\t# than root\n\t\tif l < n and lista[i] < lista[l] :\n\t\t\tlargest = l\n\t\t# Checks if root has a right child and is greater",
|
|
43
|
+ "detail": "heap",
|
|
44
|
+ "documentation": {}
|
|
45
|
+ },
|
|
46
|
+ {
|
|
47
|
+ "label": "\t\tleft",
|
|
48
|
+ "kind": 5,
|
|
49
|
+ "importPath": "heap",
|
|
50
|
+ "description": "heap",
|
|
51
|
+ "peekOfCode": "\t\tleft = 2 * i + 1\n\t\t# right child of root\n\t\tright = 2 * i + 2\n\t\t# Checks if root has a left child and is greater\n\t\t# than root\n\t\tif l < n and lista[i] < lista[l] :\n\t\t\tlargest = l\n\t\t# Checks if root has a right child and is greater\n\t\t# than root\n\t\tif r < n and lista[largest] < lista[r]:",
|
|
52
|
+ "detail": "heap",
|
|
53
|
+ "documentation": {}
|
|
54
|
+ },
|
|
55
|
+ {
|
|
56
|
+ "label": "\t\tright",
|
|
57
|
+ "kind": 5,
|
|
58
|
+ "importPath": "heap",
|
|
59
|
+ "description": "heap",
|
|
60
|
+ "peekOfCode": "\t\tright = 2 * i + 2\n\t\t# Checks if root has a left child and is greater\n\t\t# than root\n\t\tif l < n and lista[i] < lista[l] :\n\t\t\tlargest = l\n\t\t# Checks if root has a right child and is greater\n\t\t# than root\n\t\tif r < n and lista[largest] < lista[r]:\n\t\t\tlargest = r\n\t\t# If necessary, this changes root by swapping va-",
|
|
61
|
+ "detail": "heap",
|
|
62
|
+ "documentation": {}
|
|
63
|
+ },
|
|
64
|
+ {
|
|
65
|
+ "label": "\t\t\tlargest",
|
|
66
|
+ "kind": 5,
|
|
67
|
+ "importPath": "heap",
|
|
68
|
+ "description": "heap",
|
|
69
|
+ "peekOfCode": "\t\t\tlargest = l\n\t\t# Checks if root has a right child and is greater\n\t\t# than root\n\t\tif r < n and lista[largest] < lista[r]:\n\t\t\tlargest = r\n\t\t# If necessary, this changes root by swapping va-\n\t\t# lues\n\t\tlista[i], lista[largest] = lista[largest], lista[i]\n\t\t# This heapifies the root repeatedly\n\t\theapify(lista, n, largest)",
|
|
70
|
+ "detail": "heap",
|
|
71
|
+ "documentation": {}
|
|
72
|
+ },
|
|
73
|
+ {
|
|
74
|
+ "label": "\t\t\tlargest",
|
|
75
|
+ "kind": 5,
|
|
76
|
+ "importPath": "heap",
|
|
77
|
+ "description": "heap",
|
|
78
|
+ "peekOfCode": "\t\t\tlargest = r\n\t\t# If necessary, this changes root by swapping va-\n\t\t# lues\n\t\tlista[i], lista[largest] = lista[largest], lista[i]\n\t\t# This heapifies the root repeatedly\n\t\theapify(lista, n, largest)",
|
|
79
|
+ "detail": "heap",
|
|
80
|
+ "documentation": {}
|
|
81
|
+ },
|
|
82
|
+ {
|
|
83
|
+ "label": "mergeSort",
|
|
84
|
+ "kind": 2,
|
|
85
|
+ "importPath": "sorting",
|
|
86
|
+ "description": "sorting",
|
|
87
|
+ "peekOfCode": "def mergeSort(lista):\n\t# definan el algoritmo de ordenamiento mergesort\n\treturn lista\ndef heapSort(lista):\n\tn = len(lista)\n\th1 = (n // 2) - 1\n\tfor i in range(h1, -1, -1):\n\t\theap.heapify(lista, n, i)\n\tfor i in range(h1, -1, -1):\n\t\tlista[i], lista[0] = lista[0], lista[i]",
|
|
88
|
+ "detail": "sorting",
|
|
89
|
+ "documentation": {}
|
|
90
|
+ },
|
|
91
|
+ {
|
|
92
|
+ "label": "heapSort",
|
|
93
|
+ "kind": 2,
|
|
94
|
+ "importPath": "sorting",
|
|
95
|
+ "description": "sorting",
|
|
96
|
+ "peekOfCode": "def heapSort(lista):\n\tn = len(lista)\n\th1 = (n // 2) - 1\n\tfor i in range(h1, -1, -1):\n\t\theap.heapify(lista, n, i)\n\tfor i in range(h1, -1, -1):\n\t\tlista[i], lista[0] = lista[0], lista[i]\n\t\theap.heapify(lista, i, 0)\n\treturn lista\ndef quickSort(lista):",
|
|
97
|
+ "detail": "sorting",
|
|
98
|
+ "documentation": {}
|
|
99
|
+ },
|
|
100
|
+ {
|
|
101
|
+ "label": "quickSort",
|
|
102
|
+ "kind": 2,
|
|
103
|
+ "importPath": "sorting",
|
|
104
|
+ "description": "sorting",
|
|
105
|
+ "peekOfCode": "def quickSort(lista):\n\t#definan el algoritmo de ordenamiento quicksort\n\treturn lista\ndef shellSort(lista):\n\t#definan el algoritmo de ordenamiento shellsort\n\treturn lista\nmaxValor=1000 \t#define el valor maximo de los elementos de la lista\nlargoLista=1000 \t#define el largo de las listas a ordenar\nveces=100 \t\t#define las veces que se va a hacer el ordenamiento\nacumulaMerge=0 \t#variable para acumular el tiempo de ejecucion del mergesort",
|
|
106
|
+ "detail": "sorting",
|
|
107
|
+ "documentation": {}
|
|
108
|
+ },
|
|
109
|
+ {
|
|
110
|
+ "label": "shellSort",
|
|
111
|
+ "kind": 2,
|
|
112
|
+ "importPath": "sorting",
|
|
113
|
+ "description": "sorting",
|
|
114
|
+ "peekOfCode": "def shellSort(lista):\n\t#definan el algoritmo de ordenamiento shellsort\n\treturn lista\nmaxValor=1000 \t#define el valor maximo de los elementos de la lista\nlargoLista=1000 \t#define el largo de las listas a ordenar\nveces=100 \t\t#define las veces que se va a hacer el ordenamiento\nacumulaMerge=0 \t#variable para acumular el tiempo de ejecucion del mergesort\nacumulaHeap=0 \t#variable para acumular el tiempo de ejecucion del heapsort\nacumulaQuick=0 \t#variable para acumular el tiempo de ejecucion del quicksort\nacumulaShell=0 \t#variable para acumular el tiempo de ejecucion del shellsort",
|
|
115
|
+ "detail": "sorting",
|
|
116
|
+ "documentation": {}
|
|
117
|
+ },
|
|
118
|
+ {
|
|
119
|
+ "label": "\tn",
|
|
120
|
+ "kind": 5,
|
|
121
|
+ "importPath": "sorting",
|
|
122
|
+ "description": "sorting",
|
|
123
|
+ "peekOfCode": "\tn = len(lista)\n\th1 = (n // 2) - 1\n\tfor i in range(h1, -1, -1):\n\t\theap.heapify(lista, n, i)\n\tfor i in range(h1, -1, -1):\n\t\tlista[i], lista[0] = lista[0], lista[i]\n\t\theap.heapify(lista, i, 0)\n\treturn lista\ndef quickSort(lista):\n\t#definan el algoritmo de ordenamiento quicksort",
|
|
124
|
+ "detail": "sorting",
|
|
125
|
+ "documentation": {}
|
|
126
|
+ },
|
|
127
|
+ {
|
|
128
|
+ "label": "\th1",
|
|
129
|
+ "kind": 5,
|
|
130
|
+ "importPath": "sorting",
|
|
131
|
+ "description": "sorting",
|
|
132
|
+ "peekOfCode": "\th1 = (n // 2) - 1\n\tfor i in range(h1, -1, -1):\n\t\theap.heapify(lista, n, i)\n\tfor i in range(h1, -1, -1):\n\t\tlista[i], lista[0] = lista[0], lista[i]\n\t\theap.heapify(lista, i, 0)\n\treturn lista\ndef quickSort(lista):\n\t#definan el algoritmo de ordenamiento quicksort\n\treturn lista",
|
|
133
|
+ "detail": "sorting",
|
|
134
|
+ "documentation": {}
|
|
135
|
+ },
|
|
136
|
+ {
|
|
137
|
+ "label": "\tmergelista",
|
|
138
|
+ "kind": 5,
|
|
139
|
+ "importPath": "sorting",
|
|
140
|
+ "description": "sorting",
|
|
141
|
+ "peekOfCode": "\tmergelista = [randint(0,maxValor) for r in range(largoLista)] #creamos una lista con valores al azar\n\theaplista=list(mergelista)\n\tquicklista=list(mergelista)\n\tsearchlista=list(mergelista)\n\tt1 = time.process_time()\t\t\t\t\t#tomamos el tiempo inicial\n\tmergeSort(mergelista,0,len(mergelista)-1) \t#ejecutamos el algoritmo mergeSort\n\tacumulaMerge+=time.process_time() - t1\t\t#acumulamos el tiempo de ejecucion\n\tprint(mergelista)\t\t\t\t\t\t\t#desplegamos la lista\n\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\theapSort(heaplista)\t\t\t\t\t #ejecutamos el algoritmo heapSort",
|
|
142
|
+ "detail": "sorting",
|
|
143
|
+ "documentation": {}
|
|
144
|
+ },
|
|
145
|
+ {
|
|
146
|
+ "label": "\tt1",
|
|
147
|
+ "kind": 5,
|
|
148
|
+ "importPath": "sorting",
|
|
149
|
+ "description": "sorting",
|
|
150
|
+ "peekOfCode": "\tt1 = time.process_time()\t\t\t\t\t#tomamos el tiempo inicial\n\tmergeSort(mergelista,0,len(mergelista)-1) \t#ejecutamos el algoritmo mergeSort\n\tacumulaMerge+=time.process_time() - t1\t\t#acumulamos el tiempo de ejecucion\n\tprint(mergelista)\t\t\t\t\t\t\t#desplegamos la lista\n\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\theapSort(heaplista)\t\t\t\t\t #ejecutamos el algoritmo heapSort\n\tacumulaHeap+=time.process_time() - t1 \t#acumulamos el tiempo de ejecucion\n\tprint(heaplista)\t\t\t\t\t\t#desplegamos la lista\n\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\tquickSort(quicklista)\t\t\t\t\t#ejecutamos el algoritmo quickSort",
|
|
151
|
+ "detail": "sorting",
|
|
152
|
+ "documentation": {}
|
|
153
|
+ },
|
|
154
|
+ {
|
|
155
|
+ "label": "\tt1",
|
|
156
|
+ "kind": 5,
|
|
157
|
+ "importPath": "sorting",
|
|
158
|
+ "description": "sorting",
|
|
159
|
+ "peekOfCode": "\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\theapSort(heaplista)\t\t\t\t\t #ejecutamos el algoritmo heapSort\n\tacumulaHeap+=time.process_time() - t1 \t#acumulamos el tiempo de ejecucion\n\tprint(heaplista)\t\t\t\t\t\t#desplegamos la lista\n\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\tquickSort(quicklista)\t\t\t\t\t#ejecutamos el algoritmo quickSort\n\tacumulaQuick+=time.process_time() - t1\t#acumulamos el tiempo de ejecucion\n\tprint(quicklista)\t\t\t\t\t\t#desplegamos la lista\n\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\tshellSort(searchlista)\t\t\t\t\t#ejecutamos el algoritmo shellSort",
|
|
160
|
+ "detail": "sorting",
|
|
161
|
+ "documentation": {}
|
|
162
|
+ },
|
|
163
|
+ {
|
|
164
|
+ "label": "\tt1",
|
|
165
|
+ "kind": 5,
|
|
166
|
+ "importPath": "sorting",
|
|
167
|
+ "description": "sorting",
|
|
168
|
+ "peekOfCode": "\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\tquickSort(quicklista)\t\t\t\t\t#ejecutamos el algoritmo quickSort\n\tacumulaQuick+=time.process_time() - t1\t#acumulamos el tiempo de ejecucion\n\tprint(quicklista)\t\t\t\t\t\t#desplegamos la lista\n\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\tshellSort(searchlista)\t\t\t\t\t#ejecutamos el algoritmo shellSort\n\tacumulaShell+=time.process_time() - t1\t#acumulamos el tiempo de ejecucion\n\tprint(searchlista)\t\t\t\t\t\t#desplegamos la lista\n#imprimos los resultados\nprint (\"Promedio de tiempo de ejecucion de \"+ str(veces) +\" listas de largo \" + str(largoLista))",
|
|
169
|
+ "detail": "sorting",
|
|
170
|
+ "documentation": {}
|
|
171
|
+ },
|
|
172
|
+ {
|
|
173
|
+ "label": "\tt1",
|
|
174
|
+ "kind": 5,
|
|
175
|
+ "importPath": "sorting",
|
|
176
|
+ "description": "sorting",
|
|
177
|
+ "peekOfCode": "\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\tshellSort(searchlista)\t\t\t\t\t#ejecutamos el algoritmo shellSort\n\tacumulaShell+=time.process_time() - t1\t#acumulamos el tiempo de ejecucion\n\tprint(searchlista)\t\t\t\t\t\t#desplegamos la lista\n#imprimos los resultados\nprint (\"Promedio de tiempo de ejecucion de \"+ str(veces) +\" listas de largo \" + str(largoLista))\nprint (\"MergeSort \" + str(acumulaMerge/veces) + \" segundos\")\nprint (\"HeapSort \" + str(acumulaHeap/veces) + \" segundos\")\nprint (\"QuickSort \" + str(acumulaQuick/veces) + \" segundos\")\nprint (\"ShellSort \" + str(acumulaShell/veces) + \" segundos\")",
|
|
178
|
+ "detail": "sorting",
|
|
179
|
+ "documentation": {}
|
|
180
|
+ }
|
|
181
|
+]
|