|
@@ -1,774 +0,0 @@
|
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": "merge",
|
30
|
|
- "importPath": "merge",
|
31
|
|
- "description": "merge",
|
32
|
|
- "isExtraImport": true,
|
33
|
|
- "detail": "merge",
|
34
|
|
- "documentation": {}
|
35
|
|
- },
|
36
|
|
- {
|
37
|
|
- "label": "heapify",
|
38
|
|
- "kind": 2,
|
39
|
|
- "importPath": "heap",
|
40
|
|
- "description": "heap",
|
41
|
|
- "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] :",
|
42
|
|
- "detail": "heap",
|
43
|
|
- "documentation": {}
|
44
|
|
- },
|
45
|
|
- {
|
46
|
|
- "label": "\t\tlargest",
|
47
|
|
- "kind": 5,
|
48
|
|
- "importPath": "heap",
|
49
|
|
- "description": "heap",
|
50
|
|
- "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",
|
51
|
|
- "detail": "heap",
|
52
|
|
- "documentation": {}
|
53
|
|
- },
|
54
|
|
- {
|
55
|
|
- "label": "\t\tleft",
|
56
|
|
- "kind": 5,
|
57
|
|
- "importPath": "heap",
|
58
|
|
- "description": "heap",
|
59
|
|
- "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]:",
|
60
|
|
- "detail": "heap",
|
61
|
|
- "documentation": {}
|
62
|
|
- },
|
63
|
|
- {
|
64
|
|
- "label": "\t\tright",
|
65
|
|
- "kind": 5,
|
66
|
|
- "importPath": "heap",
|
67
|
|
- "description": "heap",
|
68
|
|
- "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-",
|
69
|
|
- "detail": "heap",
|
70
|
|
- "documentation": {}
|
71
|
|
- },
|
72
|
|
- {
|
73
|
|
- "label": "\t\t\tlargest",
|
74
|
|
- "kind": 5,
|
75
|
|
- "importPath": "heap",
|
76
|
|
- "description": "heap",
|
77
|
|
- "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\theapify(lista, n, largest)",
|
78
|
|
- "detail": "heap",
|
79
|
|
- "documentation": {}
|
80
|
|
- },
|
81
|
|
- {
|
82
|
|
- "label": "\t\t\tlargest",
|
83
|
|
- "kind": 5,
|
84
|
|
- "importPath": "heap",
|
85
|
|
- "description": "heap",
|
86
|
|
- "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\theapify(lista, n, largest)",
|
87
|
|
- "detail": "heap",
|
88
|
|
- "documentation": {}
|
89
|
|
- },
|
90
|
|
- {
|
91
|
|
- "label": "heapify",
|
92
|
|
- "kind": 2,
|
93
|
|
- "importPath": "heap_BACKUP_341",
|
94
|
|
- "description": "heap_BACKUP_341",
|
95
|
|
- "peekOfCode": "def heapify(lista, n, i):\n<<<<<<< HEAD\n\tlargest = i # Initialize largest as root\n\tl = 2 * i + 1 # left = 2*i + 1\n\tr = 2 * i + 2 # right = 2*i + 2\n\t# See if left child of root exists and is\n\t# greater than root\n\tif l < n and lista[i] < lista[l]:\n\t\tlargest = l\n\t# See if right child of root exists and is",
|
96
|
|
- "detail": "heap_BACKUP_341",
|
97
|
|
- "documentation": {}
|
98
|
|
- },
|
99
|
|
- {
|
100
|
|
- "label": "\tlargest",
|
101
|
|
- "kind": 5,
|
102
|
|
- "importPath": "heap_BACKUP_341",
|
103
|
|
- "description": "heap_BACKUP_341",
|
104
|
|
- "peekOfCode": "\tlargest = i # Initialize largest as root\n\tl = 2 * i + 1 # left = 2*i + 1\n\tr = 2 * i + 2 # right = 2*i + 2\n\t# See if left child of root exists and is\n\t# greater than root\n\tif l < n and lista[i] < lista[l]:\n\t\tlargest = l\n\t# See if right child of root exists and is\n\t# greater than root\n\tif r < n and lista[largest] < lista[r]:",
|
105
|
|
- "detail": "heap_BACKUP_341",
|
106
|
|
- "documentation": {}
|
107
|
|
- },
|
108
|
|
- {
|
109
|
|
- "label": "\tl",
|
110
|
|
- "kind": 5,
|
111
|
|
- "importPath": "heap_BACKUP_341",
|
112
|
|
- "description": "heap_BACKUP_341",
|
113
|
|
- "peekOfCode": "\tl = 2 * i + 1 # left = 2*i + 1\n\tr = 2 * i + 2 # right = 2*i + 2\n\t# See if left child of root exists and is\n\t# greater than root\n\tif l < n and lista[i] < lista[l]:\n\t\tlargest = l\n\t# See if right child of root exists and is\n\t# greater than root\n\tif r < n and lista[largest] < lista[r]:\n\t\tlargest = r",
|
114
|
|
- "detail": "heap_BACKUP_341",
|
115
|
|
- "documentation": {}
|
116
|
|
- },
|
117
|
|
- {
|
118
|
|
- "label": "\tr",
|
119
|
|
- "kind": 5,
|
120
|
|
- "importPath": "heap_BACKUP_341",
|
121
|
|
- "description": "heap_BACKUP_341",
|
122
|
|
- "peekOfCode": "\tr = 2 * i + 2 # right = 2*i + 2\n\t# See if left child of root exists and is\n\t# greater than root\n\tif l < n and lista[i] < lista[l]:\n\t\tlargest = l\n\t# See if right child of root exists and is\n\t# greater than root\n\tif r < n and lista[largest] < lista[r]:\n\t\tlargest = r\n\t# Change root, if needed",
|
123
|
|
- "detail": "heap_BACKUP_341",
|
124
|
|
- "documentation": {}
|
125
|
|
- },
|
126
|
|
- {
|
127
|
|
- "label": "\t\tlargest",
|
128
|
|
- "kind": 5,
|
129
|
|
- "importPath": "heap_BACKUP_341",
|
130
|
|
- "description": "heap_BACKUP_341",
|
131
|
|
- "peekOfCode": "\t\tlargest = l\n\t# See if right child of root exists and is\n\t# greater than root\n\tif r < n and lista[largest] < lista[r]:\n\t\tlargest = r\n\t# Change root, if needed\n=======\n\t# largest is root for now\n\tlargest = i\n\t# left child of root",
|
132
|
|
- "detail": "heap_BACKUP_341",
|
133
|
|
- "documentation": {}
|
134
|
|
- },
|
135
|
|
- {
|
136
|
|
- "label": "\t\tlargest",
|
137
|
|
- "kind": 5,
|
138
|
|
- "importPath": "heap_BACKUP_341",
|
139
|
|
- "description": "heap_BACKUP_341",
|
140
|
|
- "peekOfCode": "\t\tlargest = r\n\t# Change root, if needed\n=======\n\t# largest is root for now\n\tlargest = i\n\t# left child of root\n\tl = 2 * i + 1\n\t# right child of root\n\tr = 2 * i + 2\n\t# Checks if root has a left child and is greater",
|
141
|
|
- "detail": "heap_BACKUP_341",
|
142
|
|
- "documentation": {}
|
143
|
|
- },
|
144
|
|
- {
|
145
|
|
- "label": "\tlargest",
|
146
|
|
- "kind": 5,
|
147
|
|
- "importPath": "heap_BACKUP_341",
|
148
|
|
- "description": "heap_BACKUP_341",
|
149
|
|
- "peekOfCode": "\tlargest = i\n\t# left child of root\n\tl = 2 * i + 1\n\t# right child of root\n\tr = 2 * i + 2\n\t# Checks if root has a left child and is greater\n\t# than root\n\tif l < n and lista[i] < lista[l] :\n\t\tlargest = l\n\t# Checks if root has a right child and is greater",
|
150
|
|
- "detail": "heap_BACKUP_341",
|
151
|
|
- "documentation": {}
|
152
|
|
- },
|
153
|
|
- {
|
154
|
|
- "label": "\tl",
|
155
|
|
- "kind": 5,
|
156
|
|
- "importPath": "heap_BACKUP_341",
|
157
|
|
- "description": "heap_BACKUP_341",
|
158
|
|
- "peekOfCode": "\tl = 2 * i + 1\n\t# right child of root\n\tr = 2 * i + 2\n\t# Checks if root has a left child and is greater\n\t# than root\n\tif l < n and lista[i] < lista[l] :\n\t\tlargest = l\n\t# Checks if root has a right child and is greater\n\t# than root\n\tif r < n and lista[largest] < lista[r]:",
|
159
|
|
- "detail": "heap_BACKUP_341",
|
160
|
|
- "documentation": {}
|
161
|
|
- },
|
162
|
|
- {
|
163
|
|
- "label": "\tr",
|
164
|
|
- "kind": 5,
|
165
|
|
- "importPath": "heap_BACKUP_341",
|
166
|
|
- "description": "heap_BACKUP_341",
|
167
|
|
- "peekOfCode": "\tr = 2 * i + 2\n\t# Checks if root has a left child and is greater\n\t# than root\n\tif l < n and lista[i] < lista[l] :\n\t\tlargest = l\n\t# Checks if root has a right child and is greater\n\t# than root\n\tif r < n and lista[largest] < lista[r]:\n\t\tlargest = r\n\t# If necessary, this changes root by swapping va-",
|
168
|
|
- "detail": "heap_BACKUP_341",
|
169
|
|
- "documentation": {}
|
170
|
|
- },
|
171
|
|
- {
|
172
|
|
- "label": "\t\tlargest",
|
173
|
|
- "kind": 5,
|
174
|
|
- "importPath": "heap_BACKUP_341",
|
175
|
|
- "description": "heap_BACKUP_341",
|
176
|
|
- "peekOfCode": "\t\tlargest = l\n\t# Checks if root has a right child and is greater\n\t# than root\n\tif r < n and lista[largest] < lista[r]:\n\t\tlargest = r\n\t# If necessary, this changes root by swapping va-\n\t# lues\n\t\tlista[i], lista[largest] = lista[largest], lista[i]\n>>>>>>> sortingHeap\n\tif largest != i:",
|
177
|
|
- "detail": "heap_BACKUP_341",
|
178
|
|
- "documentation": {}
|
179
|
|
- },
|
180
|
|
- {
|
181
|
|
- "label": "\t\tlargest",
|
182
|
|
- "kind": 5,
|
183
|
|
- "importPath": "heap_BACKUP_341",
|
184
|
|
- "description": "heap_BACKUP_341",
|
185
|
|
- "peekOfCode": "\t\tlargest = r\n\t# If necessary, this changes root by swapping va-\n\t# lues\n\t\tlista[i], lista[largest] = lista[largest], lista[i]\n>>>>>>> sortingHeap\n\tif largest != i:\n\t\t(lista[i], lista[largest]) = (lista[largest], lista[i]) # swap\n\t\t# Heapify the root.\n\t\theapify(lista, n, largest)",
|
186
|
|
- "detail": "heap_BACKUP_341",
|
187
|
|
- "documentation": {}
|
188
|
|
- },
|
189
|
|
- {
|
190
|
|
- "label": "heapify",
|
191
|
|
- "kind": 2,
|
192
|
|
- "importPath": "heap_BASE_341",
|
193
|
|
- "description": "heap_BASE_341",
|
194
|
|
- "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] :",
|
195
|
|
- "detail": "heap_BASE_341",
|
196
|
|
- "documentation": {}
|
197
|
|
- },
|
198
|
|
- {
|
199
|
|
- "label": "\t\tlargest",
|
200
|
|
- "kind": 5,
|
201
|
|
- "importPath": "heap_BASE_341",
|
202
|
|
- "description": "heap_BASE_341",
|
203
|
|
- "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",
|
204
|
|
- "detail": "heap_BASE_341",
|
205
|
|
- "documentation": {}
|
206
|
|
- },
|
207
|
|
- {
|
208
|
|
- "label": "\t\tleft",
|
209
|
|
- "kind": 5,
|
210
|
|
- "importPath": "heap_BASE_341",
|
211
|
|
- "description": "heap_BASE_341",
|
212
|
|
- "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]:",
|
213
|
|
- "detail": "heap_BASE_341",
|
214
|
|
- "documentation": {}
|
215
|
|
- },
|
216
|
|
- {
|
217
|
|
- "label": "\t\tright",
|
218
|
|
- "kind": 5,
|
219
|
|
- "importPath": "heap_BASE_341",
|
220
|
|
- "description": "heap_BASE_341",
|
221
|
|
- "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-",
|
222
|
|
- "detail": "heap_BASE_341",
|
223
|
|
- "documentation": {}
|
224
|
|
- },
|
225
|
|
- {
|
226
|
|
- "label": "\t\t\tlargest",
|
227
|
|
- "kind": 5,
|
228
|
|
- "importPath": "heap_BASE_341",
|
229
|
|
- "description": "heap_BASE_341",
|
230
|
|
- "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)",
|
231
|
|
- "detail": "heap_BASE_341",
|
232
|
|
- "documentation": {}
|
233
|
|
- },
|
234
|
|
- {
|
235
|
|
- "label": "\t\t\tlargest",
|
236
|
|
- "kind": 5,
|
237
|
|
- "importPath": "heap_BASE_341",
|
238
|
|
- "description": "heap_BASE_341",
|
239
|
|
- "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)",
|
240
|
|
- "detail": "heap_BASE_341",
|
241
|
|
- "documentation": {}
|
242
|
|
- },
|
243
|
|
- {
|
244
|
|
- "label": "heapify",
|
245
|
|
- "kind": 2,
|
246
|
|
- "importPath": "heap_LOCAL_341",
|
247
|
|
- "description": "heap_LOCAL_341",
|
248
|
|
- "peekOfCode": "def heapify(lista, n, i):\n\tlargest = i # Initialize largest as root\n\tl = 2 * i + 1 # left = 2*i + 1\n\tr = 2 * i + 2 # right = 2*i + 2\n\t# See if left child of root exists and is\n\t# greater than root\n\tif l < n and lista[i] < lista[l]:\n\t\tlargest = l\n\t# See if right child of root exists and is\n\t# greater than root",
|
249
|
|
- "detail": "heap_LOCAL_341",
|
250
|
|
- "documentation": {}
|
251
|
|
- },
|
252
|
|
- {
|
253
|
|
- "label": "\tlargest",
|
254
|
|
- "kind": 5,
|
255
|
|
- "importPath": "heap_LOCAL_341",
|
256
|
|
- "description": "heap_LOCAL_341",
|
257
|
|
- "peekOfCode": "\tlargest = i # Initialize largest as root\n\tl = 2 * i + 1 # left = 2*i + 1\n\tr = 2 * i + 2 # right = 2*i + 2\n\t# See if left child of root exists and is\n\t# greater than root\n\tif l < n and lista[i] < lista[l]:\n\t\tlargest = l\n\t# See if right child of root exists and is\n\t# greater than root\n\tif r < n and lista[largest] < lista[r]:",
|
258
|
|
- "detail": "heap_LOCAL_341",
|
259
|
|
- "documentation": {}
|
260
|
|
- },
|
261
|
|
- {
|
262
|
|
- "label": "\tl",
|
263
|
|
- "kind": 5,
|
264
|
|
- "importPath": "heap_LOCAL_341",
|
265
|
|
- "description": "heap_LOCAL_341",
|
266
|
|
- "peekOfCode": "\tl = 2 * i + 1 # left = 2*i + 1\n\tr = 2 * i + 2 # right = 2*i + 2\n\t# See if left child of root exists and is\n\t# greater than root\n\tif l < n and lista[i] < lista[l]:\n\t\tlargest = l\n\t# See if right child of root exists and is\n\t# greater than root\n\tif r < n and lista[largest] < lista[r]:\n\t\tlargest = r",
|
267
|
|
- "detail": "heap_LOCAL_341",
|
268
|
|
- "documentation": {}
|
269
|
|
- },
|
270
|
|
- {
|
271
|
|
- "label": "\tr",
|
272
|
|
- "kind": 5,
|
273
|
|
- "importPath": "heap_LOCAL_341",
|
274
|
|
- "description": "heap_LOCAL_341",
|
275
|
|
- "peekOfCode": "\tr = 2 * i + 2 # right = 2*i + 2\n\t# See if left child of root exists and is\n\t# greater than root\n\tif l < n and lista[i] < lista[l]:\n\t\tlargest = l\n\t# See if right child of root exists and is\n\t# greater than root\n\tif r < n and lista[largest] < lista[r]:\n\t\tlargest = r\n\t# Change root, if needed",
|
276
|
|
- "detail": "heap_LOCAL_341",
|
277
|
|
- "documentation": {}
|
278
|
|
- },
|
279
|
|
- {
|
280
|
|
- "label": "\t\tlargest",
|
281
|
|
- "kind": 5,
|
282
|
|
- "importPath": "heap_LOCAL_341",
|
283
|
|
- "description": "heap_LOCAL_341",
|
284
|
|
- "peekOfCode": "\t\tlargest = l\n\t# See if right child of root exists and is\n\t# greater than root\n\tif r < n and lista[largest] < lista[r]:\n\t\tlargest = r\n\t# Change root, if needed\n\tif largest != i:\n\t\t(lista[i], lista[largest]) = (lista[largest], lista[i]) # swap\n\t\t# Heapify the root.\n\t\theapify(lista, n, largest)",
|
285
|
|
- "detail": "heap_LOCAL_341",
|
286
|
|
- "documentation": {}
|
287
|
|
- },
|
288
|
|
- {
|
289
|
|
- "label": "\t\tlargest",
|
290
|
|
- "kind": 5,
|
291
|
|
- "importPath": "heap_LOCAL_341",
|
292
|
|
- "description": "heap_LOCAL_341",
|
293
|
|
- "peekOfCode": "\t\tlargest = r\n\t# Change root, if needed\n\tif largest != i:\n\t\t(lista[i], lista[largest]) = (lista[largest], lista[i]) # swap\n\t\t# Heapify the root.\n\t\theapify(lista, n, largest)",
|
294
|
|
- "detail": "heap_LOCAL_341",
|
295
|
|
- "documentation": {}
|
296
|
|
- },
|
297
|
|
- {
|
298
|
|
- "label": "heapify",
|
299
|
|
- "kind": 2,
|
300
|
|
- "importPath": "heap_REMOTE_341",
|
301
|
|
- "description": "heap_REMOTE_341",
|
302
|
|
- "peekOfCode": "def heapify(lista, n, i):\n\t# largest is root for now\n\tlargest = i\n\t# left child of root\n\tl = 2 * i + 1\n\t# right child of root\n\tr = 2 * i + 2\n\t# Checks if root has a left child and is greater\n\t# than root\n\tif l < n and lista[i] < lista[l] :",
|
303
|
|
- "detail": "heap_REMOTE_341",
|
304
|
|
- "documentation": {}
|
305
|
|
- },
|
306
|
|
- {
|
307
|
|
- "label": "\tlargest",
|
308
|
|
- "kind": 5,
|
309
|
|
- "importPath": "heap_REMOTE_341",
|
310
|
|
- "description": "heap_REMOTE_341",
|
311
|
|
- "peekOfCode": "\tlargest = i\n\t# left child of root\n\tl = 2 * i + 1\n\t# right child of root\n\tr = 2 * i + 2\n\t# Checks if root has a left child and is greater\n\t# than root\n\tif l < n and lista[i] < lista[l] :\n\t\tlargest = l\n\t# Checks if root has a right child and is greater",
|
312
|
|
- "detail": "heap_REMOTE_341",
|
313
|
|
- "documentation": {}
|
314
|
|
- },
|
315
|
|
- {
|
316
|
|
- "label": "\tl",
|
317
|
|
- "kind": 5,
|
318
|
|
- "importPath": "heap_REMOTE_341",
|
319
|
|
- "description": "heap_REMOTE_341",
|
320
|
|
- "peekOfCode": "\tl = 2 * i + 1\n\t# right child of root\n\tr = 2 * i + 2\n\t# Checks if root has a left child and is greater\n\t# than root\n\tif l < n and lista[i] < lista[l] :\n\t\tlargest = l\n\t# Checks if root has a right child and is greater\n\t# than root\n\tif r < n and lista[largest] < lista[r]:",
|
321
|
|
- "detail": "heap_REMOTE_341",
|
322
|
|
- "documentation": {}
|
323
|
|
- },
|
324
|
|
- {
|
325
|
|
- "label": "\tr",
|
326
|
|
- "kind": 5,
|
327
|
|
- "importPath": "heap_REMOTE_341",
|
328
|
|
- "description": "heap_REMOTE_341",
|
329
|
|
- "peekOfCode": "\tr = 2 * i + 2\n\t# Checks if root has a left child and is greater\n\t# than root\n\tif l < n and lista[i] < lista[l] :\n\t\tlargest = l\n\t# Checks if root has a right child and is greater\n\t# than root\n\tif r < n and lista[largest] < lista[r]:\n\t\tlargest = r\n\t# If necessary, this changes root by swapping va-",
|
330
|
|
- "detail": "heap_REMOTE_341",
|
331
|
|
- "documentation": {}
|
332
|
|
- },
|
333
|
|
- {
|
334
|
|
- "label": "\t\tlargest",
|
335
|
|
- "kind": 5,
|
336
|
|
- "importPath": "heap_REMOTE_341",
|
337
|
|
- "description": "heap_REMOTE_341",
|
338
|
|
- "peekOfCode": "\t\tlargest = l\n\t# Checks if root has a right child and is greater\n\t# than root\n\tif r < n and lista[largest] < lista[r]:\n\t\tlargest = r\n\t# If necessary, this changes root by swapping va-\n\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)",
|
339
|
|
- "detail": "heap_REMOTE_341",
|
340
|
|
- "documentation": {}
|
341
|
|
- },
|
342
|
|
- {
|
343
|
|
- "label": "\t\tlargest",
|
344
|
|
- "kind": 5,
|
345
|
|
- "importPath": "heap_REMOTE_341",
|
346
|
|
- "description": "heap_REMOTE_341",
|
347
|
|
- "peekOfCode": "\t\tlargest = r\n\t# If necessary, this changes root by swapping va-\n\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)",
|
348
|
|
- "detail": "heap_REMOTE_341",
|
349
|
|
- "documentation": {}
|
350
|
|
- },
|
351
|
|
- {
|
352
|
|
- "label": "merge",
|
353
|
|
- "kind": 2,
|
354
|
|
- "importPath": "merge",
|
355
|
|
- "description": "merge",
|
356
|
|
- "peekOfCode": "def merge(arr, l, m, r):\n\tn1 = m - l + 1\n\tn2 = r - m\n\t# create temp arrays\n\tL = [0] * (n1)\n\tR = [0] * (n2)\n\t# Copy data to temp arrays L[] and R[]\n\tfor i in range(0, n1):\n\t\tL[i] = arr[l + i]\n\tfor j in range(0, n2):",
|
357
|
|
- "detail": "merge",
|
358
|
|
- "documentation": {}
|
359
|
|
- },
|
360
|
|
- {
|
361
|
|
- "label": "\tn1",
|
362
|
|
- "kind": 5,
|
363
|
|
- "importPath": "merge",
|
364
|
|
- "description": "merge",
|
365
|
|
- "peekOfCode": "\tn1 = m - l + 1\n\tn2 = r - m\n\t# create temp arrays\n\tL = [0] * (n1)\n\tR = [0] * (n2)\n\t# Copy data to temp arrays L[] and R[]\n\tfor i in range(0, n1):\n\t\tL[i] = arr[l + i]\n\tfor j in range(0, n2):\n\t\tR[j] = arr[m + 1 + j]",
|
366
|
|
- "detail": "merge",
|
367
|
|
- "documentation": {}
|
368
|
|
- },
|
369
|
|
- {
|
370
|
|
- "label": "\tn2",
|
371
|
|
- "kind": 5,
|
372
|
|
- "importPath": "merge",
|
373
|
|
- "description": "merge",
|
374
|
|
- "peekOfCode": "\tn2 = r - m\n\t# create temp arrays\n\tL = [0] * (n1)\n\tR = [0] * (n2)\n\t# Copy data to temp arrays L[] and R[]\n\tfor i in range(0, n1):\n\t\tL[i] = arr[l + i]\n\tfor j in range(0, n2):\n\t\tR[j] = arr[m + 1 + j]\n\t# Merge the temp arrays back into arr[l..r]",
|
375
|
|
- "detail": "merge",
|
376
|
|
- "documentation": {}
|
377
|
|
- },
|
378
|
|
- {
|
379
|
|
- "label": "\tL",
|
380
|
|
- "kind": 5,
|
381
|
|
- "importPath": "merge",
|
382
|
|
- "description": "merge",
|
383
|
|
- "peekOfCode": "\tL = [0] * (n1)\n\tR = [0] * (n2)\n\t# Copy data to temp arrays L[] and R[]\n\tfor i in range(0, n1):\n\t\tL[i] = arr[l + i]\n\tfor j in range(0, n2):\n\t\tR[j] = arr[m + 1 + j]\n\t# Merge the temp arrays back into arr[l..r]\n\ti = 0\t # Initial index of first subarray\n\tj = 0\t # Initial index of second subarray",
|
384
|
|
- "detail": "merge",
|
385
|
|
- "documentation": {}
|
386
|
|
- },
|
387
|
|
- {
|
388
|
|
- "label": "\tR",
|
389
|
|
- "kind": 5,
|
390
|
|
- "importPath": "merge",
|
391
|
|
- "description": "merge",
|
392
|
|
- "peekOfCode": "\tR = [0] * (n2)\n\t# Copy data to temp arrays L[] and R[]\n\tfor i in range(0, n1):\n\t\tL[i] = arr[l + i]\n\tfor j in range(0, n2):\n\t\tR[j] = arr[m + 1 + j]\n\t# Merge the temp arrays back into arr[l..r]\n\ti = 0\t # Initial index of first subarray\n\tj = 0\t # Initial index of second subarray\n\tk = l\t # Initial index of merged subarray",
|
393
|
|
- "detail": "merge",
|
394
|
|
- "documentation": {}
|
395
|
|
- },
|
396
|
|
- {
|
397
|
|
- "label": "\t\tL[i]",
|
398
|
|
- "kind": 5,
|
399
|
|
- "importPath": "merge",
|
400
|
|
- "description": "merge",
|
401
|
|
- "peekOfCode": "\t\tL[i] = arr[l + i]\n\tfor j in range(0, n2):\n\t\tR[j] = arr[m + 1 + j]\n\t# Merge the temp arrays back into arr[l..r]\n\ti = 0\t # Initial index of first subarray\n\tj = 0\t # Initial index of second subarray\n\tk = l\t # Initial index of merged subarray\n\twhile i < n1 and j < n2:\n\t\tif L[i] <= R[j]:\n\t\t\tarr[k] = L[i]",
|
402
|
|
- "detail": "merge",
|
403
|
|
- "documentation": {}
|
404
|
|
- },
|
405
|
|
- {
|
406
|
|
- "label": "\t\tR[j]",
|
407
|
|
- "kind": 5,
|
408
|
|
- "importPath": "merge",
|
409
|
|
- "description": "merge",
|
410
|
|
- "peekOfCode": "\t\tR[j] = arr[m + 1 + j]\n\t# Merge the temp arrays back into arr[l..r]\n\ti = 0\t # Initial index of first subarray\n\tj = 0\t # Initial index of second subarray\n\tk = l\t # Initial index of merged subarray\n\twhile i < n1 and j < n2:\n\t\tif L[i] <= R[j]:\n\t\t\tarr[k] = L[i]\n\t\t\ti += 1\n\t\telse:",
|
411
|
|
- "detail": "merge",
|
412
|
|
- "documentation": {}
|
413
|
|
- },
|
414
|
|
- {
|
415
|
|
- "label": "\ti",
|
416
|
|
- "kind": 5,
|
417
|
|
- "importPath": "merge",
|
418
|
|
- "description": "merge",
|
419
|
|
- "peekOfCode": "\ti = 0\t # Initial index of first subarray\n\tj = 0\t # Initial index of second subarray\n\tk = l\t # Initial index of merged subarray\n\twhile i < n1 and j < n2:\n\t\tif L[i] <= R[j]:\n\t\t\tarr[k] = L[i]\n\t\t\ti += 1\n\t\telse:\n\t\t\tarr[k] = R[j]\n\t\t\tj += 1",
|
420
|
|
- "detail": "merge",
|
421
|
|
- "documentation": {}
|
422
|
|
- },
|
423
|
|
- {
|
424
|
|
- "label": "\tj",
|
425
|
|
- "kind": 5,
|
426
|
|
- "importPath": "merge",
|
427
|
|
- "description": "merge",
|
428
|
|
- "peekOfCode": "\tj = 0\t # Initial index of second subarray\n\tk = l\t # Initial index of merged subarray\n\twhile i < n1 and j < n2:\n\t\tif L[i] <= R[j]:\n\t\t\tarr[k] = L[i]\n\t\t\ti += 1\n\t\telse:\n\t\t\tarr[k] = R[j]\n\t\t\tj += 1\n\t\tk += 1",
|
429
|
|
- "detail": "merge",
|
430
|
|
- "documentation": {}
|
431
|
|
- },
|
432
|
|
- {
|
433
|
|
- "label": "\tk",
|
434
|
|
- "kind": 5,
|
435
|
|
- "importPath": "merge",
|
436
|
|
- "description": "merge",
|
437
|
|
- "peekOfCode": "\tk = l\t # Initial index of merged subarray\n\twhile i < n1 and j < n2:\n\t\tif L[i] <= R[j]:\n\t\t\tarr[k] = L[i]\n\t\t\ti += 1\n\t\telse:\n\t\t\tarr[k] = R[j]\n\t\t\tj += 1\n\t\tk += 1\n\t# Copy the remaining elements of L[], if there",
|
438
|
|
- "detail": "merge",
|
439
|
|
- "documentation": {}
|
440
|
|
- },
|
441
|
|
- {
|
442
|
|
- "label": "\t\t\tarr[k]",
|
443
|
|
- "kind": 5,
|
444
|
|
- "importPath": "merge",
|
445
|
|
- "description": "merge",
|
446
|
|
- "peekOfCode": "\t\t\tarr[k] = L[i]\n\t\t\ti += 1\n\t\telse:\n\t\t\tarr[k] = R[j]\n\t\t\tj += 1\n\t\tk += 1\n\t# Copy the remaining elements of L[], if there\n\t# are any\n\twhile i < n1:\n\t\tarr[k] = L[i]",
|
447
|
|
- "detail": "merge",
|
448
|
|
- "documentation": {}
|
449
|
|
- },
|
450
|
|
- {
|
451
|
|
- "label": "\t\t\tarr[k]",
|
452
|
|
- "kind": 5,
|
453
|
|
- "importPath": "merge",
|
454
|
|
- "description": "merge",
|
455
|
|
- "peekOfCode": "\t\t\tarr[k] = R[j]\n\t\t\tj += 1\n\t\tk += 1\n\t# Copy the remaining elements of L[], if there\n\t# are any\n\twhile i < n1:\n\t\tarr[k] = L[i]\n\t\ti += 1\n\t\tk += 1\n\t# Copy the remaining elements of R[], if there",
|
456
|
|
- "detail": "merge",
|
457
|
|
- "documentation": {}
|
458
|
|
- },
|
459
|
|
- {
|
460
|
|
- "label": "\t\tarr[k]",
|
461
|
|
- "kind": 5,
|
462
|
|
- "importPath": "merge",
|
463
|
|
- "description": "merge",
|
464
|
|
- "peekOfCode": "\t\tarr[k] = L[i]\n\t\ti += 1\n\t\tk += 1\n\t# Copy the remaining elements of R[], if there\n\t# are any\n\twhile j < n2:\n\t\tarr[k] = R[j]\n\t\tj += 1\n\t\tk += 1\n# l is for left index and r is right index of the",
|
465
|
|
- "detail": "merge",
|
466
|
|
- "documentation": {}
|
467
|
|
- },
|
468
|
|
- {
|
469
|
|
- "label": "\t\tarr[k]",
|
470
|
|
- "kind": 5,
|
471
|
|
- "importPath": "merge",
|
472
|
|
- "description": "merge",
|
473
|
|
- "peekOfCode": "\t\tarr[k] = R[j]\n\t\tj += 1\n\t\tk += 1\n# l is for left index and r is right index of the\n# sub-array of arr to be sorted",
|
474
|
|
- "detail": "merge",
|
475
|
|
- "documentation": {}
|
476
|
|
- },
|
477
|
|
- {
|
478
|
|
- "label": "mergeSort",
|
479
|
|
- "kind": 2,
|
480
|
|
- "importPath": "sorting",
|
481
|
|
- "description": "sorting",
|
482
|
|
- "peekOfCode": "def mergeSort(lista, l, r):\n<<<<<<< HEAD\n\tif l < r:\n # Same as (l+r)//2, but avoids overflow for\n # large l and h\n\t\tm = l+(r-l)//2\n # Sort first and second halves\n\t\tmergeSort(lista, l, m)\n\t\tmergeSort(lista, m+1, r)\n\t\tmerge(lista, l, m, r)",
|
483
|
|
- "detail": "sorting",
|
484
|
|
- "documentation": {}
|
485
|
|
- },
|
486
|
|
- {
|
487
|
|
- "label": "heapSort",
|
488
|
|
- "kind": 2,
|
489
|
|
- "importPath": "sorting",
|
490
|
|
- "description": "sorting",
|
491
|
|
- "peekOfCode": "def heapSort(lista):\n\t# Se busca el tamaño de la lista\n\tn = len(lista)\n\theap.heapify(lista,n,0)\n\t''' Se crea un heap máximo y el último padre estará en\n\t\tla posición h1, i.e., la mitad del tamaño de la lista.\n\t\tPor lo tanto, ese sería el comienzo. \n\t'''\n\th1 = (n // 2) - 1\n\tfor i in range(h1, -1, -1):",
|
492
|
|
- "detail": "sorting",
|
493
|
|
- "documentation": {}
|
494
|
|
- },
|
495
|
|
- {
|
496
|
|
- "label": "quickSort",
|
497
|
|
- "kind": 2,
|
498
|
|
- "importPath": "sorting",
|
499
|
|
- "description": "sorting",
|
500
|
|
- "peekOfCode": "def quickSort(lista):\n\t# definan el algoritmo de ordenamiento quicksort\n\telements = len(lista)\n # Base case\n\tif elements < 2:\n\t\treturn lista\n\tcurrent_position = 0 #Position of the partitioning element\n\tfor i in range(1, elements): #Partitioning loop\n\t\tif lista[i] <= lista[0]:\n\t\t\tcurrent_position += 1",
|
501
|
|
- "detail": "sorting",
|
502
|
|
- "documentation": {}
|
503
|
|
- },
|
504
|
|
- {
|
505
|
|
- "label": "shellSort",
|
506
|
|
- "kind": 2,
|
507
|
|
- "importPath": "sorting",
|
508
|
|
- "description": "sorting",
|
509
|
|
- "peekOfCode": "def shellSort(lista):\n\t# definan el algoritmo de ordenamiento shellsort\n\t# determening the size of the list and calculates the gap value. \n\tn = len(lista)\n\tgap = n // 2\n\t# this algorithm will run until gap reaches 1 \n\twhile gap > 0:\n\t\tfor i in range(gap, n):\n\t\t\ttemp = lista[i] # storing all items from the list into temp \n\t\t\tj = i ",
|
510
|
|
- "detail": "sorting",
|
511
|
|
- "documentation": {}
|
512
|
|
- },
|
513
|
|
- {
|
514
|
|
- "label": "\t\tm",
|
515
|
|
- "kind": 5,
|
516
|
|
- "importPath": "sorting",
|
517
|
|
- "description": "sorting",
|
518
|
|
- "peekOfCode": "\t\tm = l+(r-l)//2\n # Sort first and second halves\n\t\tmergeSort(lista, l, m)\n\t\tmergeSort(lista, m+1, r)\n\t\tmerge(lista, l, m, r)\n''' Luis Andrés López Mañán\n Program written by hand as a draft on 09/19/2022\n Credit goes to GeeksForGeeks\n Link: https://www.geeksforgeeks.org/python-program-for-heap-sort/\n Last access on 09/19/2022",
|
519
|
|
- "detail": "sorting",
|
520
|
|
- "documentation": {}
|
521
|
|
- },
|
522
|
|
- {
|
523
|
|
- "label": "\tn",
|
524
|
|
- "kind": 5,
|
525
|
|
- "importPath": "sorting",
|
526
|
|
- "description": "sorting",
|
527
|
|
- "peekOfCode": "\tn = len(lista)\n\theap.heapify(lista,n,0)\n\t''' Se crea un heap máximo y el último padre estará en\n\t\tla posición h1, i.e., la mitad del tamaño de la lista.\n\t\tPor lo tanto, ese sería el comienzo. \n\t'''\n\th1 = (n // 2) - 1\n\tfor i in range(h1, -1, -1):\n\t\theap.heapify(lista, n, i)\n<<<<<<< HEAD",
|
528
|
|
- "detail": "sorting",
|
529
|
|
- "documentation": {}
|
530
|
|
- },
|
531
|
|
- {
|
532
|
|
- "label": "\th1",
|
533
|
|
- "kind": 5,
|
534
|
|
- "importPath": "sorting",
|
535
|
|
- "description": "sorting",
|
536
|
|
- "peekOfCode": "\th1 = (n // 2) - 1\n\tfor i in range(h1, -1, -1):\n\t\theap.heapify(lista, n, i)\n<<<<<<< HEAD\n\t# Se extrae los elementos uno a uno\n\th2 = n - 1\n\tfor i in range(h2, 0, -1):\n\t\t# Se intercambia, luego se hace heapify\n\t\tlista[i], lista[0] = lista[0], lista[i]\n\t\theap.heapify(lista, 0, i)",
|
537
|
|
- "detail": "sorting",
|
538
|
|
- "documentation": {}
|
539
|
|
- },
|
540
|
|
- {
|
541
|
|
- "label": "\th2",
|
542
|
|
- "kind": 5,
|
543
|
|
- "importPath": "sorting",
|
544
|
|
- "description": "sorting",
|
545
|
|
- "peekOfCode": "\th2 = n - 1\n\tfor i in range(h2, 0, -1):\n\t\t# Se intercambia, luego se hace heapify\n\t\tlista[i], lista[0] = lista[0], lista[i]\n\t\theap.heapify(lista, 0, i)\n=======\n\th2 = n - 1\n\tfor i in range(h2, 0, -1):\n\t\tlista[i], lista[0] = lista[0], lista[i]\n\t\theap.heapify(lista, 0, i)",
|
546
|
|
- "detail": "sorting",
|
547
|
|
- "documentation": {}
|
548
|
|
- },
|
549
|
|
- {
|
550
|
|
- "label": "\th2",
|
551
|
|
- "kind": 5,
|
552
|
|
- "importPath": "sorting",
|
553
|
|
- "description": "sorting",
|
554
|
|
- "peekOfCode": "\th2 = n - 1\n\tfor i in range(h2, 0, -1):\n\t\tlista[i], lista[0] = lista[0], lista[i]\n\t\theap.heapify(lista, 0, i)\n>>>>>>> sortingHeap\n\treturn lista\ndef quickSort(lista):\n\t# definan el algoritmo de ordenamiento quicksort\n\telements = len(lista)\n # Base case",
|
555
|
|
- "detail": "sorting",
|
556
|
|
- "documentation": {}
|
557
|
|
- },
|
558
|
|
- {
|
559
|
|
- "label": "\telements",
|
560
|
|
- "kind": 5,
|
561
|
|
- "importPath": "sorting",
|
562
|
|
- "description": "sorting",
|
563
|
|
- "peekOfCode": "\telements = len(lista)\n # Base case\n\tif elements < 2:\n\t\treturn lista\n\tcurrent_position = 0 #Position of the partitioning element\n\tfor i in range(1, elements): #Partitioning loop\n\t\tif lista[i] <= lista[0]:\n\t\t\tcurrent_position += 1\n\t\t\ttemp = lista[i]\n\t\t\tlista[i] = lista[current_position]",
|
564
|
|
- "detail": "sorting",
|
565
|
|
- "documentation": {}
|
566
|
|
- },
|
567
|
|
- {
|
568
|
|
- "label": "\tcurrent_position",
|
569
|
|
- "kind": 5,
|
570
|
|
- "importPath": "sorting",
|
571
|
|
- "description": "sorting",
|
572
|
|
- "peekOfCode": "\tcurrent_position = 0 #Position of the partitioning element\n\tfor i in range(1, elements): #Partitioning loop\n\t\tif lista[i] <= lista[0]:\n\t\t\tcurrent_position += 1\n\t\t\ttemp = lista[i]\n\t\t\tlista[i] = lista[current_position]\n\t\t\tlista[current_position] = temp\n\ttemp = lista[0]\n\tlista[0] = lista[current_position] \n\tlista[current_position] = temp #Brings pivot to it's appropriate position",
|
573
|
|
- "detail": "sorting",
|
574
|
|
- "documentation": {}
|
575
|
|
- },
|
576
|
|
- {
|
577
|
|
- "label": "\t\t\ttemp",
|
578
|
|
- "kind": 5,
|
579
|
|
- "importPath": "sorting",
|
580
|
|
- "description": "sorting",
|
581
|
|
- "peekOfCode": "\t\t\ttemp = lista[i]\n\t\t\tlista[i] = lista[current_position]\n\t\t\tlista[current_position] = temp\n\ttemp = lista[0]\n\tlista[0] = lista[current_position] \n\tlista[current_position] = temp #Brings pivot to it's appropriate position\n\tleft = quickSort(lista[0:current_position]) #Sorts the elements to the left of pivot\n\tright = quickSort(lista[current_position+1:elements]) #sorts the elements to the right of pivot\n\tlista = left + [lista[current_position]] + right #Merging everything together\n\treturn lista",
|
582
|
|
- "detail": "sorting",
|
583
|
|
- "documentation": {}
|
584
|
|
- },
|
585
|
|
- {
|
586
|
|
- "label": "\t\t\tlista[i]",
|
587
|
|
- "kind": 5,
|
588
|
|
- "importPath": "sorting",
|
589
|
|
- "description": "sorting",
|
590
|
|
- "peekOfCode": "\t\t\tlista[i] = lista[current_position]\n\t\t\tlista[current_position] = temp\n\ttemp = lista[0]\n\tlista[0] = lista[current_position] \n\tlista[current_position] = temp #Brings pivot to it's appropriate position\n\tleft = quickSort(lista[0:current_position]) #Sorts the elements to the left of pivot\n\tright = quickSort(lista[current_position+1:elements]) #sorts the elements to the right of pivot\n\tlista = left + [lista[current_position]] + right #Merging everything together\n\treturn lista\n''' ",
|
591
|
|
- "detail": "sorting",
|
592
|
|
- "documentation": {}
|
593
|
|
- },
|
594
|
|
- {
|
595
|
|
- "label": "\t\t\tlista[current_position]",
|
596
|
|
- "kind": 5,
|
597
|
|
- "importPath": "sorting",
|
598
|
|
- "description": "sorting",
|
599
|
|
- "peekOfCode": "\t\t\tlista[current_position] = temp\n\ttemp = lista[0]\n\tlista[0] = lista[current_position] \n\tlista[current_position] = temp #Brings pivot to it's appropriate position\n\tleft = quickSort(lista[0:current_position]) #Sorts the elements to the left of pivot\n\tright = quickSort(lista[current_position+1:elements]) #sorts the elements to the right of pivot\n\tlista = left + [lista[current_position]] + right #Merging everything together\n\treturn lista\n''' \n\tThis algorithm was taken from: https://www.programiz.com/dsa/shell-sort ",
|
600
|
|
- "detail": "sorting",
|
601
|
|
- "documentation": {}
|
602
|
|
- },
|
603
|
|
- {
|
604
|
|
- "label": "\ttemp",
|
605
|
|
- "kind": 5,
|
606
|
|
- "importPath": "sorting",
|
607
|
|
- "description": "sorting",
|
608
|
|
- "peekOfCode": "\ttemp = lista[0]\n\tlista[0] = lista[current_position] \n\tlista[current_position] = temp #Brings pivot to it's appropriate position\n\tleft = quickSort(lista[0:current_position]) #Sorts the elements to the left of pivot\n\tright = quickSort(lista[current_position+1:elements]) #sorts the elements to the right of pivot\n\tlista = left + [lista[current_position]] + right #Merging everything together\n\treturn lista\n''' \n\tThis algorithm was taken from: https://www.programiz.com/dsa/shell-sort \n\tand was adapted in order to work for this assigment.",
|
609
|
|
- "detail": "sorting",
|
610
|
|
- "documentation": {}
|
611
|
|
- },
|
612
|
|
- {
|
613
|
|
- "label": "\tlista[0]",
|
614
|
|
- "kind": 5,
|
615
|
|
- "importPath": "sorting",
|
616
|
|
- "description": "sorting",
|
617
|
|
- "peekOfCode": "\tlista[0] = lista[current_position] \n\tlista[current_position] = temp #Brings pivot to it's appropriate position\n\tleft = quickSort(lista[0:current_position]) #Sorts the elements to the left of pivot\n\tright = quickSort(lista[current_position+1:elements]) #sorts the elements to the right of pivot\n\tlista = left + [lista[current_position]] + right #Merging everything together\n\treturn lista\n''' \n\tThis algorithm was taken from: https://www.programiz.com/dsa/shell-sort \n\tand was adapted in order to work for this assigment.\n'''",
|
618
|
|
- "detail": "sorting",
|
619
|
|
- "documentation": {}
|
620
|
|
- },
|
621
|
|
- {
|
622
|
|
- "label": "\tlista[current_position]",
|
623
|
|
- "kind": 5,
|
624
|
|
- "importPath": "sorting",
|
625
|
|
- "description": "sorting",
|
626
|
|
- "peekOfCode": "\tlista[current_position] = temp #Brings pivot to it's appropriate position\n\tleft = quickSort(lista[0:current_position]) #Sorts the elements to the left of pivot\n\tright = quickSort(lista[current_position+1:elements]) #sorts the elements to the right of pivot\n\tlista = left + [lista[current_position]] + right #Merging everything together\n\treturn lista\n''' \n\tThis algorithm was taken from: https://www.programiz.com/dsa/shell-sort \n\tand was adapted in order to work for this assigment.\n'''\ndef shellSort(lista):",
|
627
|
|
- "detail": "sorting",
|
628
|
|
- "documentation": {}
|
629
|
|
- },
|
630
|
|
- {
|
631
|
|
- "label": "\tleft",
|
632
|
|
- "kind": 5,
|
633
|
|
- "importPath": "sorting",
|
634
|
|
- "description": "sorting",
|
635
|
|
- "peekOfCode": "\tleft = quickSort(lista[0:current_position]) #Sorts the elements to the left of pivot\n\tright = quickSort(lista[current_position+1:elements]) #sorts the elements to the right of pivot\n\tlista = left + [lista[current_position]] + right #Merging everything together\n\treturn lista\n''' \n\tThis algorithm was taken from: https://www.programiz.com/dsa/shell-sort \n\tand was adapted in order to work for this assigment.\n'''\ndef shellSort(lista):\n\t# definan el algoritmo de ordenamiento shellsort",
|
636
|
|
- "detail": "sorting",
|
637
|
|
- "documentation": {}
|
638
|
|
- },
|
639
|
|
- {
|
640
|
|
- "label": "\tright",
|
641
|
|
- "kind": 5,
|
642
|
|
- "importPath": "sorting",
|
643
|
|
- "description": "sorting",
|
644
|
|
- "peekOfCode": "\tright = quickSort(lista[current_position+1:elements]) #sorts the elements to the right of pivot\n\tlista = left + [lista[current_position]] + right #Merging everything together\n\treturn lista\n''' \n\tThis algorithm was taken from: https://www.programiz.com/dsa/shell-sort \n\tand was adapted in order to work for this assigment.\n'''\ndef shellSort(lista):\n\t# definan el algoritmo de ordenamiento shellsort\n\t# determening the size of the list and calculates the gap value. ",
|
645
|
|
- "detail": "sorting",
|
646
|
|
- "documentation": {}
|
647
|
|
- },
|
648
|
|
- {
|
649
|
|
- "label": "\tlista",
|
650
|
|
- "kind": 5,
|
651
|
|
- "importPath": "sorting",
|
652
|
|
- "description": "sorting",
|
653
|
|
- "peekOfCode": "\tlista = left + [lista[current_position]] + right #Merging everything together\n\treturn lista\n''' \n\tThis algorithm was taken from: https://www.programiz.com/dsa/shell-sort \n\tand was adapted in order to work for this assigment.\n'''\ndef shellSort(lista):\n\t# definan el algoritmo de ordenamiento shellsort\n\t# determening the size of the list and calculates the gap value. \n\tn = len(lista)",
|
654
|
|
- "detail": "sorting",
|
655
|
|
- "documentation": {}
|
656
|
|
- },
|
657
|
|
- {
|
658
|
|
- "label": "\tn",
|
659
|
|
- "kind": 5,
|
660
|
|
- "importPath": "sorting",
|
661
|
|
- "description": "sorting",
|
662
|
|
- "peekOfCode": "\tn = len(lista)\n\tgap = n // 2\n\t# this algorithm will run until gap reaches 1 \n\twhile gap > 0:\n\t\tfor i in range(gap, n):\n\t\t\ttemp = lista[i] # storing all items from the list into temp \n\t\t\tj = i \n\t\t\t# compares the number in temp with the 0th possition (start of list)\n\t\t\t# if temp is larger than the first element then we swap them\n\t\t\twhile j >= gap and lista[j - gap] > temp: ",
|
663
|
|
- "detail": "sorting",
|
664
|
|
- "documentation": {}
|
665
|
|
- },
|
666
|
|
- {
|
667
|
|
- "label": "\tgap",
|
668
|
|
- "kind": 5,
|
669
|
|
- "importPath": "sorting",
|
670
|
|
- "description": "sorting",
|
671
|
|
- "peekOfCode": "\tgap = n // 2\n\t# this algorithm will run until gap reaches 1 \n\twhile gap > 0:\n\t\tfor i in range(gap, n):\n\t\t\ttemp = lista[i] # storing all items from the list into temp \n\t\t\tj = i \n\t\t\t# compares the number in temp with the 0th possition (start of list)\n\t\t\t# if temp is larger than the first element then we swap them\n\t\t\twhile j >= gap and lista[j - gap] > temp: \n\t\t\t\tlista[j] = lista[j - gap]",
|
672
|
|
- "detail": "sorting",
|
673
|
|
- "documentation": {}
|
674
|
|
- },
|
675
|
|
- {
|
676
|
|
- "label": "\t\t\ttemp",
|
677
|
|
- "kind": 5,
|
678
|
|
- "importPath": "sorting",
|
679
|
|
- "description": "sorting",
|
680
|
|
- "peekOfCode": "\t\t\ttemp = lista[i] # storing all items from the list into temp \n\t\t\tj = i \n\t\t\t# compares the number in temp with the 0th possition (start of list)\n\t\t\t# if temp is larger than the first element then we swap them\n\t\t\twhile j >= gap and lista[j - gap] > temp: \n\t\t\t\tlista[j] = lista[j - gap]\n\t\t\t\tj -= gap\n\t\t\tlista[j] = temp\n\t\tgap = gap // 2 # decreases the gap to continue the loop \n\treturn lista",
|
681
|
|
- "detail": "sorting",
|
682
|
|
- "documentation": {}
|
683
|
|
- },
|
684
|
|
- {
|
685
|
|
- "label": "\t\t\tj",
|
686
|
|
- "kind": 5,
|
687
|
|
- "importPath": "sorting",
|
688
|
|
- "description": "sorting",
|
689
|
|
- "peekOfCode": "\t\t\tj = i \n\t\t\t# compares the number in temp with the 0th possition (start of list)\n\t\t\t# if temp is larger than the first element then we swap them\n\t\t\twhile j >= gap and lista[j - gap] > temp: \n\t\t\t\tlista[j] = lista[j - gap]\n\t\t\t\tj -= gap\n\t\t\tlista[j] = temp\n\t\tgap = gap // 2 # decreases the gap to continue the loop \n\treturn lista\nmaxValor=1000 \t#define el valor maximo de los elementos de la lista",
|
690
|
|
- "detail": "sorting",
|
691
|
|
- "documentation": {}
|
692
|
|
- },
|
693
|
|
- {
|
694
|
|
- "label": "\t\t\t\tlista[j]",
|
695
|
|
- "kind": 5,
|
696
|
|
- "importPath": "sorting",
|
697
|
|
- "description": "sorting",
|
698
|
|
- "peekOfCode": "\t\t\t\tlista[j] = lista[j - gap]\n\t\t\t\tj -= gap\n\t\t\tlista[j] = temp\n\t\tgap = gap // 2 # decreases the gap to continue the loop \n\treturn lista\nmaxValor=1000 \t#define el valor maximo de los elementos de la lista\nlargoLista=1000 #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",
|
699
|
|
- "detail": "sorting",
|
700
|
|
- "documentation": {}
|
701
|
|
- },
|
702
|
|
- {
|
703
|
|
- "label": "\t\t\tlista[j]",
|
704
|
|
- "kind": 5,
|
705
|
|
- "importPath": "sorting",
|
706
|
|
- "description": "sorting",
|
707
|
|
- "peekOfCode": "\t\t\tlista[j] = temp\n\t\tgap = gap // 2 # decreases the gap to continue the loop \n\treturn lista\nmaxValor=1000 \t#define el valor maximo de los elementos de la lista\nlargoLista=1000 #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",
|
708
|
|
- "detail": "sorting",
|
709
|
|
- "documentation": {}
|
710
|
|
- },
|
711
|
|
- {
|
712
|
|
- "label": "\t\tgap",
|
713
|
|
- "kind": 5,
|
714
|
|
- "importPath": "sorting",
|
715
|
|
- "description": "sorting",
|
716
|
|
- "peekOfCode": "\t\tgap = gap // 2 # decreases the gap to continue the loop \n\treturn lista\nmaxValor=1000 \t#define el valor maximo de los elementos de la lista\nlargoLista=1000 #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\nfor i in range(veces):",
|
717
|
|
- "detail": "sorting",
|
718
|
|
- "documentation": {}
|
719
|
|
- },
|
720
|
|
- {
|
721
|
|
- "label": "\tmergelista",
|
722
|
|
- "kind": 5,
|
723
|
|
- "importPath": "sorting",
|
724
|
|
- "description": "sorting",
|
725
|
|
- "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\t# print(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",
|
726
|
|
- "detail": "sorting",
|
727
|
|
- "documentation": {}
|
728
|
|
- },
|
729
|
|
- {
|
730
|
|
- "label": "\tt1",
|
731
|
|
- "kind": 5,
|
732
|
|
- "importPath": "sorting",
|
733
|
|
- "description": "sorting",
|
734
|
|
- "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\t# print(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\t# print(heaplista)\t\t\t\t\t\t#desplegamos la lista\n\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\tquickresult = quickSort(quicklista)\t\t\t\t\t#ejecutamos el algoritmo quickSort",
|
735
|
|
- "detail": "sorting",
|
736
|
|
- "documentation": {}
|
737
|
|
- },
|
738
|
|
- {
|
739
|
|
- "label": "\tt1",
|
740
|
|
- "kind": 5,
|
741
|
|
- "importPath": "sorting",
|
742
|
|
- "description": "sorting",
|
743
|
|
- "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\t# print(heaplista)\t\t\t\t\t\t#desplegamos la lista\n\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\tquickresult = quickSort(quicklista)\t\t\t\t\t#ejecutamos el algoritmo quickSort\n\tacumulaQuick+=time.process_time() - t1\t#acumulamos el tiempo de ejecucion\n\t# print(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",
|
744
|
|
- "detail": "sorting",
|
745
|
|
- "documentation": {}
|
746
|
|
- },
|
747
|
|
- {
|
748
|
|
- "label": "\tt1",
|
749
|
|
- "kind": 5,
|
750
|
|
- "importPath": "sorting",
|
751
|
|
- "description": "sorting",
|
752
|
|
- "peekOfCode": "\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\tquickresult = quickSort(quicklista)\t\t\t\t\t#ejecutamos el algoritmo quickSort\n\tacumulaQuick+=time.process_time() - t1\t#acumulamos el tiempo de ejecucion\n\t# print(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\t# print(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))",
|
753
|
|
- "detail": "sorting",
|
754
|
|
- "documentation": {}
|
755
|
|
- },
|
756
|
|
- {
|
757
|
|
- "label": "\tquickresult",
|
758
|
|
- "kind": 5,
|
759
|
|
- "importPath": "sorting",
|
760
|
|
- "description": "sorting",
|
761
|
|
- "peekOfCode": "\tquickresult = quickSort(quicklista)\t\t\t\t\t#ejecutamos el algoritmo quickSort\n\tacumulaQuick+=time.process_time() - t1\t#acumulamos el tiempo de ejecucion\n\t# print(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\t# print(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\")",
|
762
|
|
- "detail": "sorting",
|
763
|
|
- "documentation": {}
|
764
|
|
- },
|
765
|
|
- {
|
766
|
|
- "label": "\tt1",
|
767
|
|
- "kind": 5,
|
768
|
|
- "importPath": "sorting",
|
769
|
|
- "description": "sorting",
|
770
|
|
- "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\t# print(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\")",
|
771
|
|
- "detail": "sorting",
|
772
|
|
- "documentation": {}
|
773
|
|
- }
|
774
|
|
-]
|